Class: OCI::Retry::Internal::RetryState
- Inherits:
-
Object
- Object
- OCI::Retry::Internal::RetryState
- Defined in:
- lib/oci/retry/internal/retry_state.rb
Overview
A property bag containing the current state of making a retriable call
Instance Attribute Summary collapse
-
#current_attempt_number ⇒ Object
readonly
The current number of attempts which have been made.
-
#last_exception ⇒ Exception
The last exception which was raised when making a retriable call.
-
#start_time_epoch_millis ⇒ Integer
readonly
When we started making retriable calls, in epoch milliseconds.
Instance Method Summary collapse
-
#increment_attempts ⇒ Object
Increments the number of attempts which have been made by 1.
-
#initialize ⇒ RetryState
constructor
A new instance of RetryState.
-
#start ⇒ Object
Sets the #start_time_epoch_millis property to the current time in epoch milliseconds.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ RetryState
Returns a new instance of RetryState.
24 25 26 |
# File 'lib/oci/retry/internal/retry_state.rb', line 24 def initialize @current_attempt_number = 0 end |
Instance Attribute Details
#current_attempt_number ⇒ Object (readonly)
The current number of attempts which have been made. This is one-based (i.e. the first attempt is 1, the second is 2 etc.)
12 13 14 |
# File 'lib/oci/retry/internal/retry_state.rb', line 12 def current_attempt_number @current_attempt_number end |
#last_exception ⇒ Exception
The last exception which was raised when making a retriable call
22 23 24 |
# File 'lib/oci/retry/internal/retry_state.rb', line 22 def last_exception @last_exception end |
#start_time_epoch_millis ⇒ Integer (readonly)
When we started making retriable calls, in epoch milliseconds
17 18 19 |
# File 'lib/oci/retry/internal/retry_state.rb', line 17 def start_time_epoch_millis @start_time_epoch_millis end |
Instance Method Details
#increment_attempts ⇒ Object
Increments the number of attempts which have been made by 1
29 30 31 |
# File 'lib/oci/retry/internal/retry_state.rb', line 29 def increment_attempts @current_attempt_number += 1 end |
#start ⇒ Object
Sets the #start_time_epoch_millis property to the current time in epoch milliseconds. This can only be done once.
35 36 37 38 39 |
# File 'lib/oci/retry/internal/retry_state.rb', line 35 def start raise 'The start_time for the retry state has already been set' unless @start_time_epoch_millis.nil? @start_time_epoch_millis = (Time.now.to_f * 1000).to_i end |
#to_s ⇒ Object
41 42 43 44 45 |
# File 'lib/oci/retry/internal/retry_state.rb', line 41 def to_s "{ 'current_attempt': '#{current_attempt_number}', " \ "'start_time_epoch_millis': '#{start_time_epoch_millis}', " \ "'last_exception': '#{last_exception}' }" end |