Skip to main content

SupervisorBuilder

Struct SupervisorBuilder 

Source
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

Source

pub fn new() -> Self

Source

pub fn with_task(self, name: &str, task: impl SupervisedTask + Clone) -> Self

Source

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).

Source

pub fn with_health_check_interval(self, interval: Duration) -> Self

Source

pub fn with_max_restart_attempts(self, attempts: u32) -> Self

Source

pub fn with_unlimited_restarts(self) -> Self

Source

pub fn with_base_restart_delay(self, delay: Duration) -> Self

Source

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.

Source

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.

Source

pub fn build(self) -> Supervisor

Trait Implementations§

Source§

impl Default for SupervisorBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.