pub struct DeadlineScheduler<DS: DeadlineStore> { /* private fields */ }Expand description
A background task that polls DeadlineStore::due_now and dispatches
deadline commands to the owning processes via a caller-supplied function.
Obtain via EngineContext::run_deadline_scheduler and drive by spawning
DeadlineScheduler::run in a Tokio task.
§Dispatch function
The dispatch function receives a fired Deadline and returns a future
that dispatches the appropriate timeout command to the process. The function
is responsible for resuming the correct workflow and calling execute.
After the future completes, the scheduler cancels the deadline from the
store regardless of the dispatch outcome (to prevent re-firing).
ⓘ
use std::time::Duration;
let scheduler = ctx.run_deadline_scheduler(
|deadline| async move {
tracing::warn!(
deadline_id = %deadline.deadline_id(),
label = %deadline.label(),
"deadline fired",
);
Ok(())
},
100,
Duration::from_secs(30),
);
tokio::spawn(async move { scheduler.run().await });Implementations§
Source§impl<DS: DeadlineStore> DeadlineScheduler<DS>
impl<DS: DeadlineStore> DeadlineScheduler<DS>
Auto Trait Implementations§
impl<DS> !RefUnwindSafe for DeadlineScheduler<DS>
impl<DS> !UnwindSafe for DeadlineScheduler<DS>
impl<DS> Freeze for DeadlineScheduler<DS>where
DS: Freeze,
impl<DS> Send for DeadlineScheduler<DS>
impl<DS> Sync for DeadlineScheduler<DS>
impl<DS> Unpin for DeadlineScheduler<DS>where
DS: Unpin,
impl<DS> UnsafeUnpin for DeadlineScheduler<DS>where
DS: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more