pub struct Supervisor { /* private fields */ }Expand description
OTP-inspired supervision tree.
Supervise critical actors and automatically restart them on failure using one of three strategies:
OneForOne— restart only the crashed actor.OneForAll— restart all supervised actors.RestForOne— restart the crashed actor and all registered after it.
§Usage
ⓘ
let mut sup = Supervisor::new(system.clone());
sup.supervise("main", main_factory, SupervisorStrategy::OneForOne, 10, 60.0, 2.0);
sup.supervise("monitor", monitor_factory, SupervisorStrategy::OneForOne, 10, 60.0, 1.0);
sup.start().await?;Implementations§
Source§impl Supervisor
impl Supervisor
pub fn new(system: ActorSystem) -> Self
pub fn with_poll_interval(system: ActorSystem, poll_interval: Duration) -> Self
Sourcepub fn supervise(
&mut self,
name: impl Into<String>,
factory: ActorFactory,
strategy: SupervisorStrategy,
max_restarts: u32,
restart_window_secs: f64,
restart_delay_secs: f64,
) -> &mut Self
pub fn supervise( &mut self, name: impl Into<String>, factory: ActorFactory, strategy: SupervisorStrategy, max_restarts: u32, restart_window_secs: f64, restart_delay_secs: f64, ) -> &mut Self
Register an actor to be supervised. Call before Supervisor::start.
Auto Trait Implementations§
impl Freeze for Supervisor
impl !RefUnwindSafe for Supervisor
impl Send for Supervisor
impl Sync for Supervisor
impl Unpin for Supervisor
impl !UnwindSafe for Supervisor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more