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.
25 26 27 |
# File 'lib/oci/retry/internal/retry_state.rb', line 25 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.)
13 14 15 |
# File 'lib/oci/retry/internal/retry_state.rb', line 13 def current_attempt_number @current_attempt_number end |
#last_exception ⇒ Exception
The last exception which was raised when making a retriable call
23 24 25 |
# File 'lib/oci/retry/internal/retry_state.rb', line 23 def last_exception @last_exception end |
#start_time_epoch_millis ⇒ Integer (readonly)
When we started making retriable calls, in epoch milliseconds
18 19 20 |
# File 'lib/oci/retry/internal/retry_state.rb', line 18 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
30 31 32 |
# File 'lib/oci/retry/internal/retry_state.rb', line 30 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.
36 37 38 39 40 |
# File 'lib/oci/retry/internal/retry_state.rb', line 36 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
42 43 44 45 46 |
# File 'lib/oci/retry/internal/retry_state.rb', line 42 def to_s "{ 'current_attempt': '#{current_attempt_number}', " \ "'start_time_epoch_millis': '#{start_time_epoch_millis}', " \ "'last_exception': '#{last_exception}' }" end |