Class: OpenAICompatibleErrors::RetryPlan
- Inherits:
-
Object
- Object
- OpenAICompatibleErrors::RetryPlan
- Defined in:
- lib/openai_compatible_errors/retry.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#delay_ms ⇒ Object
readonly
Returns the value of attribute delay_ms.
-
#delay_source ⇒ Object
readonly
Returns the value of attribute delay_source.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Instance Method Summary collapse
- #do_not_retry? ⇒ Boolean
-
#initialize(action:, reason:, delay_ms: nil, delay_source: nil) ⇒ RetryPlan
constructor
A new instance of RetryPlan.
- #manual_decision? ⇒ Boolean
- #retry? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(action:, reason:, delay_ms: nil, delay_source: nil) ⇒ RetryPlan
Returns a new instance of RetryPlan.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/openai_compatible_errors/retry.rb', line 86 def initialize(action:, reason:, delay_ms: nil, delay_source: nil) action_symbol = action.is_a?(Symbol) || action.is_a?(String) ? action.to_sym : nil reason_symbol = reason.is_a?(Symbol) || reason.is_a?(String) ? reason.to_sym : nil @action = RETRY_ACTIONS.include?(action_symbol) ? action_symbol : :manual_decision @reason = RETRY_REASONS.include?(reason_symbol) ? reason_symbol : :invalid_context @delay_ms = delay_ms.is_a?(Integer) && delay_ms >= 0 ? delay_ms : nil source_symbol = delay_source.is_a?(Symbol) || delay_source.is_a?(String) ? delay_source.to_sym : nil @delay_source = DELAY_SOURCES.include?(source_symbol) ? source_symbol : nil freeze end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
84 85 86 |
# File 'lib/openai_compatible_errors/retry.rb', line 84 def action @action end |
#delay_ms ⇒ Object (readonly)
Returns the value of attribute delay_ms.
84 85 86 |
# File 'lib/openai_compatible_errors/retry.rb', line 84 def delay_ms @delay_ms end |
#delay_source ⇒ Object (readonly)
Returns the value of attribute delay_source.
84 85 86 |
# File 'lib/openai_compatible_errors/retry.rb', line 84 def delay_source @delay_source end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
84 85 86 |
# File 'lib/openai_compatible_errors/retry.rb', line 84 def reason @reason end |
Instance Method Details
#do_not_retry? ⇒ Boolean
101 102 103 |
# File 'lib/openai_compatible_errors/retry.rb', line 101 def do_not_retry? @action == :do_not_retry end |
#manual_decision? ⇒ Boolean
105 106 107 |
# File 'lib/openai_compatible_errors/retry.rb', line 105 def manual_decision? @action == :manual_decision end |
#retry? ⇒ Boolean
97 98 99 |
# File 'lib/openai_compatible_errors/retry.rb', line 97 def retry? @action == :retry end |
#to_h ⇒ Object
109 110 111 112 |
# File 'lib/openai_compatible_errors/retry.rb', line 109 def to_h { action: @action, reason: @reason, delay_ms: @delay_ms, delay_source: @delay_source }.compact.freeze end |