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
Perform delay if and only if retriable.
If positional argument error
is provided, the retriable logic uses
retry_codes
. Otherwise, timeout
is used.
- (Boolean) — Whether the delay was executed.
#delay
def delay() -> Numeric
Current delay value in seconds.
- (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.
#initial_delay
def initial_delay() -> Numeric
- (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.
- 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.
- (RetryPolicy) — a new instance of RetryPolicy
#max_delay
def max_delay() -> Numeric
- (Numeric) — Maximum delay in seconds.
#multiplier
def multiplier() -> Numeric
- (Numeric) — The delay scaling factor for each subsequent retry attempt.
#perform_delay
def perform_delay(error = nil) -> Boolean
Perform delay if and only if retriable.
If positional argument error
is provided, the retriable logic uses
retry_codes
. Otherwise, timeout
is used.
- (Boolean) — Whether the delay was executed.
#perform_delay!
def perform_delay!() -> Boolean
Perform delay.
- (Boolean) — Whether the delay was executed.
#perform_delay_count
def perform_delay_count() -> Integer
Current number of times the delay has been performed
- (Integer)
#retry_codes
def retry_codes() -> Array<Integer>
- (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.
- 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
- (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