pub enum SupervisionStrategy {
OneForOne {
max_restarts: u32,
within: Duration,
},
OneForAll {
max_restarts: u32,
within: Duration,
},
RestForOne {
max_restarts: u32,
within: Duration,
},
SimpleOneForOne,
}Expand description
How a supervisor should handle child failures.
Variants§
OneForOne
Restart only the failed child.
When a child crashes, only that child is restarted. Other children are unaffected.
Fields
OneForAll
Restart all children when one fails.
When a child crashes, all children are terminated and restarted. Use when children are tightly coupled.
Fields
RestForOne
Restart failed child and those started after it.
When a child crashes, that child and all children started after it are terminated and restarted. Children started before are unaffected. Use for dependent chains of actors.
Fields
SimpleOneForOne
Don’t restart, just acknowledge failure.
No automatic restart is performed. Useful for dynamic, temporary children where failures are expected.
Implementations§
Source§impl SupervisionStrategy
impl SupervisionStrategy
Sourcepub fn one_for_one(max_restarts: u32, within: Duration) -> Self
pub fn one_for_one(max_restarts: u32, within: Duration) -> Self
Create a one-for-one strategy.
Sourcepub fn one_for_all(max_restarts: u32, within: Duration) -> Self
pub fn one_for_all(max_restarts: u32, within: Duration) -> Self
Create a one-for-all strategy.
Sourcepub fn rest_for_one(max_restarts: u32, within: Duration) -> Self
pub fn rest_for_one(max_restarts: u32, within: Duration) -> Self
Create a rest-for-one strategy.
Sourcepub fn simple_one_for_one() -> Self
pub fn simple_one_for_one() -> Self
Create a simple one-for-one strategy.