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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright 2025-2026 Colliery Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//! # Retry Policy System
//!
//! This module provides a comprehensive retry policy system for Cloacina tasks,
//! including configurable backoff strategies, jitter, and conditional retry logic.
//!
//! ## Overview
//!
//! The retry system allows tasks to define sophisticated retry behavior:
//! - **Configurable retry limits** with per-task policies
//! - **Multiple backoff strategies** including exponential, linear, and custom
//! - **Jitter support** to prevent thundering herd problems
//! - **Conditional retries** based on error types and conditions
//! - **Production-ready resilience patterns**
//!
//! ## Usage
//!
//! ```rust
//! use cloacina::retry::{RetryPolicy, BackoffStrategy, RetryCondition};
//! use std::time::Duration;
//!
//! let policy = RetryPolicy::builder()
//! .max_attempts(5)
//! .backoff_strategy(BackoffStrategy::Exponential {
//! base: 2.0,
//! multiplier: 1.0
//! })
//! .initial_delay(Duration::from_millis(100))
//! .max_delay(Duration::from_secs(30))
//! .with_jitter(true)
//! .retry_condition(RetryCondition::AllErrors)
//! .build();
//! ```
//!
//! ## Key Components
//!
//! ### RetryPolicy
//! The main configuration struct that defines how a task should behave when it fails.
//! It includes settings for retry attempts, backoff strategy, delays, and retry conditions.
//!
//! ### BackoffStrategy
//! Defines how the delay between retry attempts should increase. Available strategies:
//! - **Fixed**: Same delay for every retry
//! - **Linear**: Delay increases linearly with each attempt
//! - **Exponential**: Delay increases exponentially with each attempt
//! - **Custom**: Reserved for future extensibility
//!
//! ### RetryCondition
//! Determines whether a failed task should be retried based on:
//! - **AllErrors**: Retry on any error (default)
//! - **Never**: Never retry
//! - **TransientOnly**: Retry only for transient errors
//! - **ErrorPattern**: Retry based on error message patterns
//!
//! ## Best Practices
//!
//! 1. **Jitter**: Always enable jitter in production to prevent thundering herd problems
//! 2. **Max Delay**: Set a reasonable max_delay to prevent excessive wait times
//! 3. **Error Conditions**: Use specific retry conditions to avoid retrying on permanent failures
//! 4. **Backoff Strategy**: Choose exponential backoff for most cases, linear for predictable failures
// Re-export all retry types from cloacina_workflow
// This ensures type compatibility between macro-generated code and runtime
pub use ;