saddle_core/lifecycle.rs
1use std::{future::Future, pin::Pin};
2
3use crate::Result;
4
5pub type LifecycleFuture<'a> = Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
6
7/// Object-safe lifecycle contract used by the Saddle application assembler.
8///
9/// Implementations must be safe to start once and shut down once. Ordering and
10/// graceful-drain policy belong to `saddle-runtime`, not this contract.
11pub trait ComponentLifecycle: Send + Sync {
12 fn name(&self) -> &'static str;
13
14 fn start(&self) -> LifecycleFuture<'_>;
15
16 fn shutdown(&self) -> LifecycleFuture<'_>;
17}