Skip to main content

run_leased_background_tasks

Function run_leased_background_tasks 

Source
pub async fn run_leased_background_tasks<Store, StartFn>(
    store: Store,
    config: RuntimeLeaseConfig,
    shutdown_token: CancellationToken,
    start_background_tasks: StartFn,
)
where Store: RuntimeLeaseStore, StartFn: FnMut(CancellationToken) -> BackgroundTasks + Send,
Expand description

Runs a singleton background task group behind a Forge runtime lease.

This helper keeps the repeated product glue in one place: acquire a process-level singleton lease, start a BackgroundTasks group with the lease-scoped shutdown token, and shut that group down when the lease is lost or the process is terminating. Products still own the lease id, lease store, worker list, and runtime owner id.