Trait transact::scheduler::Scheduler[][src]

pub trait Scheduler: Send {
    fn set_result_callback(
        &mut self,
        callback: Box<dyn Fn(Option<BatchExecutionResult>) + Send>
    ) -> Result<(), SchedulerError>;
fn set_error_callback(
        &mut self,
        callback: Box<dyn Fn(SchedulerError) + Send>
    ) -> Result<(), SchedulerError>;
fn add_batch(&mut self, batch: BatchPair) -> Result<(), SchedulerError>;
fn cancel(&mut self) -> Result<Vec<BatchPair>, SchedulerError>;
fn finalize(&mut self) -> Result<(), SchedulerError>;
fn take_task_iterator(
        &mut self
    ) -> Result<Box<dyn Iterator<Item = ExecutionTask> + Send>, SchedulerError>;
fn new_notifier(
        &mut self
    ) -> Result<Box<dyn ExecutionTaskCompletionNotifier>, SchedulerError>; }
Expand description

Schedules batches and transactions and returns execution results.

Cleanup

Implementations of the Scheduler trait may need to perform some cleanup before they are dropped (shutting down background threads, for example). If required, implementors of this trait should perform cleanup when the scheduler is finalized and all batch results have been sent using the result callback. This will happen for a finalized scheduler when all scheduled batches are executed, or when the finalized scheduler is cancelled.

This ensures that the scheduler returns all batches to the caller before cleaning itself up. Consumers of this trait must ensure that the scheduler is finalized and all batch results have been received (by cancelling and/or waiting for a None result on the callback) before dropping the scheduler, otherwise system resources may be leaked.

Required methods

Sets a callback to receive results from processing batches. The order the results are received is not guarenteed to be the same order as the batches were added with add_batch. If callback is called with None, all batch results have been sent (only used when the scheduler has been finalized and no more batches will be added).

Sets a callback to receive any errors encountered by the Scheduler that are not related to a specific batch.

Adds a BatchPair to the scheduler.

Drops any unexecuted batches from this scheduler and immediately aborts any batches that are currently executing. If already finalized, the scheduler should indicate that no more batch results will be sent by passing a None result to the callback.

Returns a Vec of the unscheduled and aborted BatchPairs.

Finalizes the scheduler, which will disable the ability to add more batches. After this is called, add_batch() will be return a FinalizedSchedulerError.

Returns an iterator that returns transactions to be executed.

Returns a newly allocated ExecutionTaskCompletionNotifier which allows sending a notification to the scheduler that indicates the task has been executed.

Implementors