SchedulerBackend

Trait SchedulerBackend 

Source
pub trait SchedulerBackend {
    // Required methods
    fn should_sync(&self) -> bool;
    fn sync(
        &mut self,
        scheduled_tasks: &mut BinaryHeap<ScheduledTask>,
    ) -> Result<(), BeatError>;
}
Expand description

A SchedulerBackend is in charge of keeping track of the internal state of the scheduler according to some source of truth, such as a database.

The default scheduler backend, LocalSchedulerBackend, doesn’t do any external synchronization, so the source of truth is just the locally defined schedules.

Required Methods§

Source

fn should_sync(&self) -> bool

Check whether the internal state of the scheduler should be synchronized. If this method returns true, then sync will be called as soon as possible.

Source

fn sync( &mut self, scheduled_tasks: &mut BinaryHeap<ScheduledTask>, ) -> Result<(), BeatError>

Synchronize the internal state of the scheduler.

This method is called in the pauses between scheduled tasks. Synchronization should be as quick as possible, as it may otherwise delay the execution of due tasks. If synchronization is slow, it should be done incrementally (i.e., it should span multiple calls to sync).

This method will not be called if should_sync returns false.

Implementors§