pub struct SupervisorBuilder { /* private fields */ }Expand description
Builds a Supervisor with configurable parameters.
with_task() and configuration methods can be called in any order;
task restart settings are applied uniformly at build() time.
Implementations§
Source§impl SupervisorBuilder
impl SupervisorBuilder
pub fn new() -> Self
pub fn with_task(self, name: &str, task: impl SupervisedTask + Clone) -> Self
Sourcepub fn with_max_backoff_exponent(self, exponent: u32) -> Self
pub fn with_max_backoff_exponent(self, exponent: u32) -> Self
Caps the exponent in the backoff formula:
delay = base_restart_delay * 2^min(attempt, max_backoff_exponent).
pub fn with_health_check_interval(self, interval: Duration) -> Self
pub fn with_max_restart_attempts(self, attempts: u32) -> Self
pub fn with_unlimited_restarts(self) -> Self
pub fn with_base_restart_delay(self, delay: Duration) -> Self
Sourcepub fn with_task_being_stable_after(self, delay: Duration) -> Self
pub fn with_task_being_stable_after(self, delay: Duration) -> Self
Once a task has been healthy for this long, its restart counter resets to zero.
Sourcepub fn with_dead_tasks_threshold(
self,
threshold_percentage: Option<f64>,
) -> Self
pub fn with_dead_tasks_threshold( self, threshold_percentage: Option<f64>, ) -> Self
Shuts down the supervisor if the fraction of dead tasks exceeds
threshold_percentage (0.0 – 1.0). None disables the check.
pub fn build(self) -> Supervisor
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SupervisorBuilder
impl !RefUnwindSafe for SupervisorBuilder
impl Send for SupervisorBuilder
impl !Sync for SupervisorBuilder
impl Unpin for SupervisorBuilder
impl UnsafeUnpin for SupervisorBuilder
impl !UnwindSafe for SupervisorBuilder
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