pub struct Executor { /* 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 Executor
impl Executor
Sourcepub fn new(on_error: impl Fn(SyncError) + Send + Sync + 'static) -> Executor
pub fn new(on_error: impl Fn(SyncError) + Send + Sync + 'static) -> Executor
Create a new instance with default concurrency.
Use the given on_error function to handle non-fatal errors during execution.
Non-fatal errors occur during storage operations (e.g., creating items), while
fatal errors occur when interacting with the status database.
Default concurrency is 4. Use with_concurrency to
customize it.
Sourcepub fn with_concurrency(self, concurrency: usize) -> Self
pub fn with_concurrency(self, concurrency: usize) -> Self
Set the concurrency level for operation execution.
Controls how many operations can execute in parallel. Higher values may improve performance but increase resource usage.
Sourcepub async fn execute_stream(
&self,
storage_a: Arc<dyn Storage>,
storage_b: Arc<dyn Storage>,
operations: impl Stream<Item = Result<Operation, PlanError>>,
status: &StatusDatabase,
) -> ExecutionResult
pub async fn execute_stream( &self, storage_a: Arc<dyn Storage>, storage_b: Arc<dyn Storage>, operations: impl Stream<Item = Result<Operation, PlanError>>, status: &StatusDatabase, ) -> ExecutionResult
Executes a stream of operations with controlled concurrency.
§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. 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 callback is invoked. This allows handling
individual errors without interrupting the overall operation.