1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! # Restart policies.
//!
//! [`RestartPolicy`] decides whether a task is started again after an attempt finishes.
//!
//! It answers only the "restart or stop?" question. Retry delay is handled by [`BackoffPolicy`](crate::BackoffPolicy).
//!
//! | Policy | On `Ok(())` | On retryable error |
//! |-----------------------------------------|---------------------------------|---------------------------|
//! | [`Never`](RestartPolicy::Never) | Stop | Stop |
//! | [`OnFailure`](RestartPolicy::OnFailure) | Stop | Restart with backoff |
//! | [`Always`](RestartPolicy::Always) | Restart after optional interval | Restart with backoff |
//!
//! Fatal errors and cooperative cancellation stop the task for all policies.
//!
//! ## Choosing a policy
//!
//! - Use [`Never`](RestartPolicy::Never) for one-shot tasks.
//! - Use [`OnFailure`](RestartPolicy::OnFailure) for long-running workers.
//! - Use [`Always`](RestartPolicy::Always) for periodic tasks that finish and should run again.
/// Policy controlling whether a task is restarted after an attempt finishes.
///
/// This policy decides restart eligibility. Retry timing is controlled by [`BackoffPolicy`](crate::BackoffPolicy).
///
/// # Also
///
/// - [`BackoffPolicy`](crate::BackoffPolicy) - retry delays after failures
/// - [`TaskSpec`](crate::TaskSpec) - stores restart, backoff, timeout, and retry limit