Class: ComplyanceSDK::Config::RetryConfig
- Inherits:
-
Object
- Object
- ComplyanceSDK::Config::RetryConfig
- Defined in:
- lib/complyance_sdk/config/retry_config.rb
Overview
Configuration for retry behavior
Instance Attribute Summary collapse
-
#backoff_multiplier ⇒ Object
Backoff multiplier for exponential backoff.
-
#base_delay ⇒ Object
Base delay between retries in seconds.
-
#circuit_breaker_enabled ⇒ Object
Whether circuit breaker is enabled.
-
#circuit_breaker_timeout ⇒ Object
Circuit breaker timeout in seconds.
-
#failure_threshold ⇒ Object
Failure threshold for circuit breaker.
-
#jitter_factor ⇒ Object
Jitter factor to add randomness to retry delays.
-
#max_attempts ⇒ Object
Maximum number of retry attempts.
-
#max_delay ⇒ Object
Maximum delay between retries in seconds.
-
#retryable_error_codes ⇒ Object
Error codes that should trigger a retry.
-
#retryable_http_codes ⇒ Object
HTTP status codes that should trigger a retry.
Class Method Summary collapse
-
.aggressive ⇒ RetryConfig
Create an aggressive retry configuration.
-
.conservative ⇒ RetryConfig
Create a conservative retry configuration.
-
.default ⇒ RetryConfig
Create a default retry configuration.
-
.none ⇒ RetryConfig
Create a retry configuration with no retries.
Instance Method Summary collapse
-
#circuit_breaker_config ⇒ Hash
Get circuit breaker configuration.
-
#circuit_breaker_enabled? ⇒ Boolean
Check if circuit breaker is enabled.
-
#initialize(options = {}) ⇒ RetryConfig
constructor
Initialize a new retry configuration.
Constructor Details
#initialize(options = {}) ⇒ RetryConfig
Initialize a new retry configuration
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 49 def initialize( = {}) @max_attempts = .fetch(:max_attempts, 3) @base_delay = .fetch(:base_delay, 1000) # Base delay in milliseconds to match Java @max_delay = .fetch(:max_delay, 30000) # Max delay in milliseconds to match Java @backoff_multiplier = .fetch(:backoff_multiplier, 2.0) @jitter_factor = .fetch(:jitter_factor, 0.2) @circuit_breaker_enabled = .fetch(:circuit_breaker_enabled, true) @failure_threshold = .fetch(:failure_threshold, 5) @circuit_breaker_timeout = .fetch(:circuit_breaker_timeout, 60.0) @retryable_http_codes = .fetch(:retryable_http_codes, [408, 429, 500, 502, 503, 504]) @retryable_error_codes = .fetch(:retryable_error_codes, [:network_error, :timeout_error, :rate_limited, :temporary_error]) end |
Instance Attribute Details
#backoff_multiplier ⇒ Object
Backoff multiplier for exponential backoff
17 18 19 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 17 def backoff_multiplier @backoff_multiplier end |
#base_delay ⇒ Object
Base delay between retries in seconds
11 12 13 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 11 def base_delay @base_delay end |
#circuit_breaker_enabled ⇒ Object
Whether circuit breaker is enabled
23 24 25 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 23 def circuit_breaker_enabled @circuit_breaker_enabled end |
#circuit_breaker_timeout ⇒ Object
Circuit breaker timeout in seconds
29 30 31 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 29 def circuit_breaker_timeout @circuit_breaker_timeout end |
#failure_threshold ⇒ Object
Failure threshold for circuit breaker
26 27 28 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 26 def failure_threshold @failure_threshold end |
#jitter_factor ⇒ Object
Jitter factor to add randomness to retry delays
20 21 22 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 20 def jitter_factor @jitter_factor end |
#max_attempts ⇒ Object
Maximum number of retry attempts
8 9 10 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 8 def max_attempts @max_attempts end |
#max_delay ⇒ Object
Maximum delay between retries in seconds
14 15 16 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 14 def max_delay @max_delay end |
#retryable_error_codes ⇒ Object
Error codes that should trigger a retry
35 36 37 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 35 def retryable_error_codes @retryable_error_codes end |
#retryable_http_codes ⇒ Object
HTTP status codes that should trigger a retry
32 33 34 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 32 def retryable_http_codes @retryable_http_codes end |
Class Method Details
.aggressive ⇒ RetryConfig
Create an aggressive retry configuration
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 72 def self.aggressive new( max_attempts: 7, base_delay: 0.2, max_delay: 10.0, backoff_multiplier: 1.5, jitter_factor: 0.1, circuit_breaker_timeout: 30.0 ) end |
.conservative ⇒ RetryConfig
Create a conservative retry configuration
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 86 def self.conservative new( max_attempts: 3, base_delay: 2.0, max_delay: 60.0, backoff_multiplier: 3.0, jitter_factor: 0.3, failure_threshold: 3, circuit_breaker_timeout: 120.0 ) end |
.default ⇒ RetryConfig
Create a default retry configuration
65 66 67 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 65 def self.default new end |
.none ⇒ RetryConfig
Create a retry configuration with no retries
101 102 103 104 105 106 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 101 def self.none new( max_attempts: 1, circuit_breaker_enabled: false ) end |
Instance Method Details
#circuit_breaker_config ⇒ Hash
Get circuit breaker configuration
111 112 113 114 115 116 117 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 111 def circuit_breaker_config { failure_threshold: @failure_threshold, timeout_seconds: @circuit_breaker_timeout.to_i, success_threshold: 1 } end |
#circuit_breaker_enabled? ⇒ Boolean
Check if circuit breaker is enabled
122 123 124 |
# File 'lib/complyance_sdk/config/retry_config.rb', line 122 def circuit_breaker_enabled? @circuit_breaker_enabled end |