retry_policies/retry_policy.rs
1use chrono::{DateTime, Utc};
2
3pub trait RetryPolicy {
4 /// Determine if a task should be retried according to a retry policy.
5 fn should_retry(&self, n_past_retries: u32) -> RetryDecision;
6}
7
8/// Outcome of evaluating a retry policy for a failed task.
9#[derive(Debug)]
10pub enum RetryDecision {
11 /// Retry after the specified timestamp.
12 Retry { execute_after: DateTime<Utc> },
13 /// Give up.
14 DoNotRetry,
15}