#[non_exhaustive]pub enum RestartPolicy {
Never,
OnFailure,
Always {
interval_ms: Option<u64>,
},
}Expand description
Determines whether a task should be automatically restarted after completion or failure.
| Variant | Behaviour |
|---|---|
Never | Do not restart under any circumstances |
OnFailure | Restart only when the task ends with an error |
Always | Restart unconditionally (immediate or periodic via interval) |
Always { interval_ms: None } restarts immediately;
Always { interval_ms: Some(N) } waits N ms between runs (periodic task).
Cancellation (via controller or shutdown) is not treated as failure and will not trigger a restart.
§Also
BackoffPolicydelay between restart attempts.TaskSpeccarriesrestartas a field.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Never
Never restart the task.
OnFailure
Restart the task only if it failed (non-zero exit, error, panic, etc.).
Always
Always restart after completion.
interval_ms: None- restart immediately after the previous run completes (tight loop tempered only byBackoffPolicyon failure).interval_ms: Some(n)- waitnmilliseconds between runs (periodic task).Some(0)is treated as immediate and is semantically identical toNone; preferNonefor clarity.
Caution: interval_ms: None (or Some(0)) is appropriate for a task
that blocks (a long-running service that should respawn immediately if it
ever exits). For a task that returns quickly on success it produces a hot
restart loop with no delay floor — use interval_ms: Some(n) for anything
that completes fast and is meant to repeat.
Implementations§
Trait Implementations§
Source§impl Clone for RestartPolicy
impl Clone for RestartPolicy
Source§fn clone(&self) -> RestartPolicy
fn clone(&self) -> RestartPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RestartPolicy
Source§impl Debug for RestartPolicy
impl Debug for RestartPolicy
Source§impl Default for RestartPolicy
impl Default for RestartPolicy
Source§fn default() -> RestartPolicy
fn default() -> RestartPolicy
Source§impl<'de> Deserialize<'de> for RestartPolicy
impl<'de> Deserialize<'de> for RestartPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for RestartPolicy
Source§impl FromStr for RestartPolicy
impl FromStr for RestartPolicy
Source§type Err = ModelError
type Err = ModelError
Source§impl PartialEq for RestartPolicy
impl PartialEq for RestartPolicy
Source§fn eq(&self, other: &RestartPolicy) -> bool
fn eq(&self, other: &RestartPolicy) -> bool
self and other values to be equal, and is used by ==.