Skip to main content

ComponentLifecycle

Trait ComponentLifecycle 

Source
pub trait ComponentLifecycle: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn start(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>>;
    fn shutdown(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>>;

    // Provided method
    fn shutdown_with_primary(
        &self,
        _primary: Option<DiagnosticOccurrence>,
    ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>> { ... }
}
Expand description

Object-safe lifecycle contract used by the Saddle application assembler.

Implementations must be safe to start once and shut down once. Ordering and graceful-drain policy belong to saddle-runtime, not this contract.

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn start( &self, ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>>

Source

fn shutdown( &self, ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>>

Provided Methods§

Source

fn shutdown_with_primary( &self, _primary: Option<DiagnosticOccurrence>, ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>>

The cleanup owner may correlate its original source with an existing primary before recording. Components without their own source writer retain the ordinary shutdown behavior.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ComponentLifecycle for Observer

Source§

fn name(&self) -> &'static str

Source§

fn start( &self, ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>>

Source§

fn shutdown( &self, ) -> Pin<Box<dyn Future<Output = Result<(), SaddleError>> + Send + '_>>

Implementors§