FactoryLifecycleHooks

Trait FactoryLifecycleHooks 

Source
pub trait FactoryLifecycleHooks<TKey, TMsg>: State + Sync
where TKey: JobKey, TMsg: Message,
{ // Provided methods fn on_factory_started<'life0, 'async_trait>( &'life0 self, factory_ref: ActorRef<FactoryMessage<TKey, TMsg>>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... } fn on_factory_stopped<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... } fn on_factory_draining<'life0, 'async_trait>( &'life0 self, factory_ref: ActorRef<FactoryMessage<TKey, TMsg>>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... } }
Expand description

Hooks for crate::factory::Factory lifecycle events based on the underlying actor’s lifecycle.

Provided Methods§

Source

fn on_factory_started<'life0, 'async_trait>( &'life0 self, factory_ref: ActorRef<FactoryMessage<TKey, TMsg>>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Called when the factory has completed it’s startup routine but PRIOR to processing any messages. Just before this point, the factory is ready to accept and process requests and all workers are started.

This hook is there to provide custom startup logic you want to make sure has run prior to processing messages on workers

WARNING: An error or panic returned here WILL shutdown the factory and notify supervisors

Source

fn on_factory_stopped<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Called when the factory has completed it’s shutdown routine but PRIOR to fully exiting and notifying any relevant supervisors. Just prior to this call the factory has processed its last message and will process no more messages.

This hook is there to provide custom shutdown logic you want to make sure has run prior to the factory fully exiting

Source

fn on_factory_draining<'life0, 'async_trait>( &'life0 self, factory_ref: ActorRef<FactoryMessage<TKey, TMsg>>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Called when the factory has received a signal to drain requests and exit after draining has completed.

This hook is to provide the ability to notify external services that the factory is in the process of shutting down. If the factory is never “drained” formally, this hook won’t be called.

WARNING: An error or panic returned here WILL shutdown the factory and notify supervisors

Implementors§