Skip to main content

Lifecycle

Trait Lifecycle 

Source
pub trait Lifecycle:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn on_init(&self, _ctx: AppContext) -> BoxFuture<'_, Result<(), BoxError>> { ... }
    fn on_bootstrap(
        &self,
        _ctx: AppContext,
    ) -> BoxFuture<'_, Result<(), BoxError>> { ... }
    fn on_shutdown(
        &self,
        _ctx: AppContext,
    ) -> BoxFuture<'_, Result<(), BoxError>> { ... }
}
Expand description

Hooks implemented by a provider and registered with ModuleBuilder::lifecycle.

At boot, after every singleton is built, on_init runs for every registered provider in module dependency order, then on_bootstrap in the same order. At shutdown, on_shutdown runs in reverse order.

Provided Methods§

Source

fn on_init(&self, _ctx: AppContext) -> BoxFuture<'_, Result<(), BoxError>>

Runs once all singletons exist.

Source

fn on_bootstrap(&self, _ctx: AppContext) -> BoxFuture<'_, Result<(), BoxError>>

Runs after every on_init succeeded.

Source

fn on_shutdown(&self, _ctx: AppContext) -> BoxFuture<'_, Result<(), BoxError>>

Runs during graceful shutdown, after tracked tasks have drained.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§