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.



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_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.)



13
14
15
# File 'lib/oci/retry/internal/retry_state.rb', line 13

def current_attempt_number
  @current_attempt_number
end

#last_exceptionException

The last exception which was raised when making a retriable call

Returns:

  • (Exception)


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

def last_exception
  @last_exception
end

#start_time_epoch_millisInteger (readonly)

When we started making retriable calls, in epoch milliseconds

Returns:

  • (Integer)


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_attemptsObject

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

#startObject

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_sObject



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