pub trait BackgroundService: Send {
// Required methods
fn name(&self) -> &str;
fn run(
self: Box<Self>,
state: Arc<StateMap>,
shutdown: Shutdown,
) -> BoxFuture<()>;
}Expand description
Long-running work started after on_startup, stopped after connection drain.
Services are process-local — they are not shared across processes. Prefer one service per concern (UDP socket, queue worker, …).
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".