pub struct Executor<I: Item> { /* private fields */ }Expand description
Executes a plan or individual actions.
At this time, an executor can only execute a plan, but in future it may be able to execute a stream of actions for keeping collections continuously in sync.
Implementations§
Source§impl<I: Item> Executor<I>
impl<I: Item> Executor<I>
Sourcepub fn new(on_error: fn(_: SyncError<I>)) -> Executor<I>
pub fn new(on_error: fn(_: SyncError<I>)) -> Executor<I>
Create a new instance.
Use the given on_error function to handle non-fatal errors. See Executor::plan for
further details on error handling.
Sourcepub async fn plan(
&self,
plan: Plan<I>,
status: &StatusDatabase,
) -> Result<(), StatusError>
pub async fn plan( &self, plan: Plan<I>, status: &StatusDatabase, ) -> Result<(), StatusError>
Executes a whole plan.
§Errors
Returns Err(_) if a fatal error occurred when interacting with the status database. Fatal
errors are errors that occur when interacting with the status database, which tracks the
current state of multiple storages. When a fatal error occurs, neither the status database
nor the Executor instance should be re-used until the underlying issue is resolved.
When a non-fatal error occurs, the on_error shall be invoked. E.g.: when the plan
requires creating many items, if a single item fails, the error for this operation is
passed to the on_error function, while the overall operation continues. This allows
handling individual errors (e.g.: displaying them to a user) without interrupting the
operation or having to wait for the completion of the entire operation.