pub struct Supervisor { /* private fields */ }Expand description
A supervisor that manages child agents with restart strategies.
Implementations§
Source§impl Supervisor
impl Supervisor
Sourcepub fn new(strategy: Strategy, config: RestartConfig) -> Self
pub fn new(strategy: Strategy, config: RestartConfig) -> Self
Create a new supervisor with the given strategy and restart configuration.
Sourcepub fn add_child<F, Fut>(
&mut self,
name: impl Into<String>,
restart_policy: RestartPolicy,
spawn_fn: F,
)
pub fn add_child<F, Fut>( &mut self, name: impl Into<String>, restart_policy: RestartPolicy, spawn_fn: F, )
Add a child to the supervisor.
The spawn function should create the agent and return its future.
Sourcepub async fn run(&mut self) -> SageResult<()>
pub async fn run(&mut self) -> SageResult<()>
Start all children and begin supervision.
This method runs until all children have terminated (according to their restart policies) or the circuit breaker trips.
Auto Trait Implementations§
impl Freeze for Supervisor
impl !RefUnwindSafe for Supervisor
impl Send for Supervisor
impl !Sync for Supervisor
impl Unpin for Supervisor
impl UnsafeUnpin 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