Class: OpenAICompatibleErrors::RetryPolicy
- Inherits:
-
Object
- Object
- OpenAICompatibleErrors::RetryPolicy
- Defined in:
- lib/openai_compatible_errors/retry.rb
Instance Attribute Summary collapse
-
#base_delay_ms ⇒ Object
readonly
Returns the value of attribute base_delay_ms.
-
#jitter ⇒ Object
readonly
Returns the value of attribute jitter.
-
#max_attempts ⇒ Object
readonly
Returns the value of attribute max_attempts.
-
#max_delay_ms ⇒ Object
readonly
Returns the value of attribute max_delay_ms.
-
#max_elapsed_ms ⇒ Object
readonly
Returns the value of attribute max_elapsed_ms.
Instance Method Summary collapse
-
#initialize(max_attempts: 3, max_elapsed_ms: 30_000, base_delay_ms: 500, max_delay_ms: 10_000, jitter: :full) ⇒ RetryPolicy
constructor
A new instance of RetryPolicy.
Constructor Details
#initialize(max_attempts: 3, max_elapsed_ms: 30_000, base_delay_ms: 500, max_delay_ms: 10_000, jitter: :full) ⇒ RetryPolicy
Returns a new instance of RetryPolicy.
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/openai_compatible_errors/retry.rb', line 55 def initialize(max_attempts: 3, max_elapsed_ms: 30_000, base_delay_ms: 500, max_delay_ms: 10_000, jitter: :full) @max_attempts = positive_integer(max_attempts) @max_elapsed_ms = positive_integer(max_elapsed_ms) @base_delay_ms = non_negative_integer(base_delay_ms) @max_delay_ms = positive_integer(max_delay_ms) jitter_symbol = jitter.is_a?(Symbol) || jitter.is_a?(String) ? jitter.to_sym : :full @jitter = %i[full none].include?(jitter_symbol) ? jitter_symbol : :full raise ArgumentError, "max_delay_ms must be at least base_delay_ms" if @max_delay_ms < @base_delay_ms freeze end |
Instance Attribute Details
#base_delay_ms ⇒ Object (readonly)
Returns the value of attribute base_delay_ms.
52 53 54 |
# File 'lib/openai_compatible_errors/retry.rb', line 52 def base_delay_ms @base_delay_ms end |
#jitter ⇒ Object (readonly)
Returns the value of attribute jitter.
52 53 54 |
# File 'lib/openai_compatible_errors/retry.rb', line 52 def jitter @jitter end |
#max_attempts ⇒ Object (readonly)
Returns the value of attribute max_attempts.
52 53 54 |
# File 'lib/openai_compatible_errors/retry.rb', line 52 def max_attempts @max_attempts end |
#max_delay_ms ⇒ Object (readonly)
Returns the value of attribute max_delay_ms.
52 53 54 |
# File 'lib/openai_compatible_errors/retry.rb', line 52 def max_delay_ms @max_delay_ms end |
#max_elapsed_ms ⇒ Object (readonly)
Returns the value of attribute max_elapsed_ms.
52 53 54 |
# File 'lib/openai_compatible_errors/retry.rb', line 52 def max_elapsed_ms @max_elapsed_ms end |