Struct apalis_core::monitor::Monitor
source · pub struct Monitor<E> { /* private fields */ }Expand description
A monitor for coordinating and managing a collection of workers.
Implementations§
source§impl<E: Executor + Clone + Send + 'static + Sync> Monitor<E>
impl<E: Executor + Clone + Send + 'static + Sync> Monitor<E>
sourcepub fn register<J: Send + Sync + 'static, S: Service<Request<J>> + Send + 'static + Clone, P: Backend<Request<J>> + 'static>(
self,
worker: Worker<Ready<S, P>>
) -> Self
pub fn register<J: Send + Sync + 'static, S: Service<Request<J>> + Send + 'static + Clone, P: Backend<Request<J>> + 'static>( self, worker: Worker<Ready<S, P>> ) -> Self
Registers a single instance of a Worker
sourcepub fn register_with_count<J: Send + Sync + 'static, S: Service<Request<J>> + Send + 'static + Clone, P: Backend<Request<J>> + 'static>(
self,
count: usize,
worker: Worker<Ready<S, P>>
) -> Self
pub fn register_with_count<J: Send + Sync + 'static, S: Service<Request<J>> + Send + 'static + Clone, P: Backend<Request<J>> + 'static>( self, count: usize, worker: Worker<Ready<S, P>> ) -> Self
sourcepub async fn run(self) -> Result<()>
pub async fn run(self) -> Result<()>
Runs the monitor and all its registered workers until they have all completed.
§Errors
If the monitor fails to shutdown gracefully, an std::io::Error will be returned.
§Remarks
If a timeout has been set using the shutdown_timeout method, the monitor
will wait for all workers to complete up to the timeout duration before exiting.
If the timeout is reached and workers have not completed, the monitor will log a warning
message and exit forcefully.
source§impl<E> Monitor<E>
impl<E> Monitor<E>
sourcepub fn new() -> Selfwhere
E: Default,
pub fn new() -> Selfwhere
E: Default,
Creates a new monitor instance.
§Returns
A new monitor instance, with an empty collection of workers.
sourcepub fn new_with_executor(executor: E) -> Self
pub fn new_with_executor(executor: E) -> Self
Creates a new monitor instance with an executor
§Returns
A new monitor instance, with an empty collection of workers.
sourcepub fn set_executor<NE: Executor>(self, executor: NE) -> Monitor<NE>
pub fn set_executor<NE: Executor>(self, executor: NE) -> Monitor<NE>
Sets a custom executor for the monitor, allowing the usage of another runtime apart from Tokio.
The executor must implement the Executor trait.