Skip to main content

TimerHandler

Trait TimerHandler 

Source
pub trait TimerHandler<S: NamespaceStore>: MaybeSend + MaybeSync {
    // Required methods
    fn kind(&self) -> TimerKind;
    fn fire<'a>(
        &'a self,
        ctx: &'a TimerCtx<'a, S>,
        timer: &'a DueTimer,
    ) -> BoxFuture<'a, Result<Fired, StoreError>>;

    // Provided method
    fn max_per_tick(&self) -> Option<u32> { ... }
}
Expand description

Handles a due timer in its own partition.

fire may run more than once for the same timer. Every effect outside the returned batch MUST be idempotent. Effects inside the batch are applied at most once per timer row (guarded by the row’s original value). Allow room for the core’s Equals/Delete and a reschedule Absent/Put within the store’s batch limits. Cross-partition effects require an outbox.

Required Methods§

Source

fn kind(&self) -> TimerKind

The kind this handler decodes.

Source

fn fire<'a>( &'a self, ctx: &'a TimerCtx<'a, S>, timer: &'a DueTimer, ) -> BoxFuture<'a, Result<Fired, StoreError>>

Prepare effects; the core atomically guards and removes the timer.

Provided Methods§

Source

fn max_per_tick(&self) -> Option<u32>

Lowers the shared TickBudget::max_per_kind allowance for this kind.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§