pub trait StepLifecycle:
Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn shutdown<'life0, 'async_trait>(
&'life0 self,
reason: StepShutdownReason,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Lifecycle hook for stateful pipeline steps that own background work
(timers, buckets, gap-detectors, queues) beyond a single process() call.
Stateless processors do NOT implement this trait. The runtime collects
Arc<dyn StepLifecycle> at compile time and drains them in route order
during stop_route and hot-swap. See ADR-0022.
Why &self, not &mut self? Lifecycle uses &mut self for exclusive
start/stop of services. StepLifecycle is dispatched through
Arc<dyn StepLifecycle> carried inside ArcSwap pipeline snapshots, so it
MUST be &self (shared-reference, interior-mutability) for Arc cloning and
concurrent snapshots to work. See ADR-0022.
shutdown MUST be idempotent. By the time it is called, intake is cancelled
and the pipeline task has been joined, so no process() is in flight.
Err is best-effort: the runtime logs and continues (it does NOT fail
stop_route), mirroring CamelContext::stop service handling.
Required Methods§
fn shutdown<'life0, 'async_trait>(
&'life0 self,
reason: StepShutdownReason,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".