Struct SupervisorBuilder

Source
pub struct SupervisorBuilder { /* private fields */ }
Expand description

Builds a Supervisor instance with configurable parameters.

Allows customization of task timeout, heartbeat interval, health check timing, and per-task restart settings.

Implementations§

Source§

impl SupervisorBuilder

Source

pub fn new() -> Self

Creates a new builder with default configuration values.

Source

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

Adds a task to the supervisor with the specified name.

Source

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

Sets the interval between health checks.

Source

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

Sets the maximum number of restart attempts for tasks.

Source

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

Sets the base delay for task restarts, used in exponential backoff.

Source

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

Sets the delay after which a task is considered stable and healthy. When a task is considered stable, its restarts are reset to zero.

Source

pub fn with_dead_tasks_threshold( self, threshold_percentage: Option<f64>, ) -> Self

Sets the threshold for the percentage of dead tasks that will trigger a supervisor shutdown.

The threshold_percentage should be a value between 0.0 (0%) and 1.0 (100%). If the percentage of dead tasks exceeds this value, the supervisor will shut down and return an error.

Source

pub fn build(self) -> Supervisor

Constructs the Supervisor with the configured settings.

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.