Class: OCI::Retry::Internal::RetryState

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeRetryState

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_numberObject (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_exceptionException

The last exception which was raised when making a retriable call

Returns:

  • (Exception)


22
23
24
# File 'lib/oci/retry/internal/retry_state.rb', line 22

def last_exception
  @last_exception
end

#start_time_epoch_millisInteger (readonly)

When we started making retriable calls, in epoch milliseconds

Returns:

  • (Integer)


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_attemptsObject

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

#startObject

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_sObject



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