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
impl SupervisorBuilder
Sourcepub fn with_task(self, name: &str, task: impl CloneableSupervisedTask) -> Self
pub fn with_task(self, name: &str, task: impl CloneableSupervisedTask) -> Self
Adds a task to the supervisor with the specified name.
Sourcepub fn with_health_check_interval(self, interval: Duration) -> Self
pub fn with_health_check_interval(self, interval: Duration) -> Self
Sets the interval between health checks.
Sourcepub fn with_max_restart_attempts(self, attempts: u32) -> Self
pub fn with_max_restart_attempts(self, attempts: u32) -> Self
Sets the maximum number of restart attempts for tasks.
Sourcepub fn with_base_restart_delay(self, delay: Duration) -> Self
pub fn with_base_restart_delay(self, delay: Duration) -> Self
Sets the base delay for task restarts, used in exponential backoff.
Sourcepub fn with_task_being_stable_after(self, delay: Duration) -> Self
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.
Sourcepub fn with_dead_tasks_threshold(
self,
threshold_percentage: Option<f64>,
) -> Self
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.
Sourcepub fn build(self) -> Supervisor
pub fn build(self) -> Supervisor
Constructs the Supervisor
with the configured settings.