Skip to main content

Runnable

Trait Runnable 

Source
pub trait Runnable<S>:
    Send
    + Sync
    + 'static {
    // Required method
    fn run(&self, state: S) -> TaskFuture;
}
Expand description

Capability trait for providers that produce a long-running runtime task.

run() is the ONLY place in the lifecycle for long-running work (accept loops, listeners, periodic tickers). It must NOT appear in register() or Provider::boot().

Config-driven gating: if the provider is disabled at runtime (e.g. an enabled: false config flag, or a single-instance service whose pinned worker_id doesn’t match this worker), the future returned here MUST short-circuit and return Ok(()) immediately instead of starting the long task. The provider stays registered for downstream capability lookups; it just doesn’t run on this process.

Required Methods§

Source

fn run(&self, state: S) -> TaskFuture

Build the task future to be spawned by the bootstrap/supervisor layer.

NOTICE (convention): If this future returns Err, implementation should log contextual failure details itself (provider/task specific metadata).

Reason:

  • Runtime layer handles lifecycle/control-flow only.
  • Runtime cannot reliably attach provider-specific business context.
  • Non-critical runnable errors are not centrally logged to avoid duplicate/no-context error lines.

Implementors§