Skip to main content

run_dispatch_worker

Function run_dispatch_worker 

Source
pub async fn run_dispatch_worker<State, BaseFn, MaxFn, WakeFn, WakeFut, DispatchFn, DispatchFut>(
    task_name: &'static str,
    shutdown_token: CancellationToken,
    state: State,
    base_interval_fn: BaseFn,
    max_interval_fn: MaxFn,
    wakeup: WakeFn,
    dispatch_iteration: DispatchFn,
)
where State: Clone + Send + Sync + 'static, BaseFn: Fn(&State) -> Duration + Send + Sync + 'static, MaxFn: Fn(&State) -> Duration + Send + Sync + 'static, WakeFn: Fn(State) -> WakeFut + Send + Sync + 'static, WakeFut: Future<Output = ()> + Send, DispatchFn: Fn(State, CancellationToken) -> DispatchFut + Send + Sync + 'static, DispatchFut: Future<Output = BackgroundTaskDispatchIteration> + Send,
Expand description

Runs a wakeable dispatch loop with adaptive idle backoff.

Product crates provide the wakeup future and one dispatch iteration closure. The iteration closure is responsible for claim/execute logic, panic recovery if desired, metrics, and persistence of runtime task history.