Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Runners

Runners execute pipeline steps. pondrs provides two built-in runners and lets you select between them at runtime.

The Runner trait

pub trait Runner {
    fn name(&self) -> &'static str;

    fn run<E>(
        &self,
        pipe: &impl Steps<E>,
        catalog: &impl Serialize,
        params: &impl Serialize,
        hooks: &impl Hooks,
    ) -> Result<(), E>
    where
        E: From<PondError> + Send + Sync + Display + Debug + 'static;
}
  • name() — identifies the runner for CLI selection (--runner sequential)
  • run() — executes the pipeline, calling hooks at each lifecycle point

The Runners trait

Multiple runners compose as tuples, enabling runtime selection:

pub trait Runners {
    fn first_name(&self) -> &'static str;
    fn run_by_name<E>(&self, name: &str, ...) -> Option<Result<(), E>>;
    fn for_each_name(&self, f: &mut dyn FnMut(&str));
}

The default runners depend on the feature set:

  • std(SequentialRunner, ParallelRunner) — sequential is the default
  • no_std(SequentialRunner,) — only sequential is available

Selecting a runner

Via CLI:

$ my_app run                       # uses default (sequential)
$ my_app run --runner parallel     # uses parallel runner
$ my_app run --runner sequential   # explicit sequential

Via code:

App::new(catalog, params)
    .with_runners((SequentialRunner, ParallelRunner))
    .execute(pipeline)?;

Custom runners

You can implement Runner for your own types. Add them to the runners tuple:

App::new(catalog, params)
    .with_runners((SequentialRunner, ParallelRunner, MyDistributedRunner))
    .execute(pipeline)?;
$ my_app run --runner my_distributed

This chapter covers: