gapic-common - Class Gapic::Common::RetryPolicy (v0.25.0)

Reference documentation and code samples for the gapic-common class Gapic::Common::RetryPolicy.

Gapic Common retry policy base class.

Inherits

  • Object

Methods

#call

def call(error = nil) -> Boolean
Aliases

Perform delay if and only if retriable.

If positional argument error is provided, the retriable logic uses retry_codes. Otherwise, timeout is used.

Returns
  • (Boolean) — Whether the delay was executed.

#delay

def delay() -> Numeric

Current delay value in seconds.

Returns
  • (Numeric) — Time delay in seconds.

#dup

def dup() -> RetryPolicy

Returns a duplicate in a non-executing state, i.e. with the deadline and current delay reset.

Returns

#initial_delay

def initial_delay() -> Numeric
Returns
  • (Numeric) — Initial delay in seconds.

#initialize

def initialize(initial_delay: nil, max_delay: nil, multiplier: nil, retry_codes: nil, timeout: nil) -> RetryPolicy

Create new Gapic::Common::RetryPolicy instance.

Parameters
  • initial_delay (Numeric) (defaults to: nil) — Initial delay in seconds.
  • max_delay (Numeric) (defaults to: nil) — Maximum delay in seconds.
  • multiplier (Numeric) (defaults to: nil) — The delay scaling factor for each subsequent retry attempt.
  • retry_codes (Array<String|Integer>) (defaults to: nil) — List of retry codes.
  • timeout (Numeric) (defaults to: nil) — Timeout threshold value in seconds.
Returns

#max_delay

def max_delay() -> Numeric
Returns
  • (Numeric) — Maximum delay in seconds.

#multiplier

def multiplier() -> Numeric
Returns
  • (Numeric) — The delay scaling factor for each subsequent retry attempt.

#perform_delay

def perform_delay(error = nil) -> Boolean
Alias Of: #call

Perform delay if and only if retriable.

If positional argument error is provided, the retriable logic uses retry_codes. Otherwise, timeout is used.

Returns
  • (Boolean) — Whether the delay was executed.

#perform_delay!

def perform_delay!() -> Boolean

Perform delay.

Returns
  • (Boolean) — Whether the delay was executed.

#perform_delay_count

def perform_delay_count() -> Integer

Current number of times the delay has been performed

Returns
  • (Integer)

#retry_codes

def retry_codes() -> Array<Integer>
Returns
  • (Array<Integer>) — List of retry codes.

#start!

def start!(mock_delay: false)

Start tracking the deadline and delay by initializing those values.

This is normally done when the object is constructed, but it can be done explicitly in order to reinitialize the state in case this retry policy was created in the past or is being reused.

Parameter
  • mock_delay (boolean, Proc) (defaults to: false) — if truthy, delays are "mocked", meaning they do not actually take time, but are measured as if they did, which is useful for tests. If set to a Proc, it will be called whenever a delay would happen, and passed the delay in seconds, also useful for testing.

#timeout

def timeout() -> Numeric
Returns
  • (Numeric) — Timeout threshold value in seconds.

Constants

DEFAULT_INITIAL_DELAY

value: 1

DEFAULT_MAX_DELAY

value: 15

DEFAULT_MULTIPLIER

value: 1.3

DEFAULT_RETRY_CODES

value: [].freeze

DEFAULT_TIMEOUT

value: 3600