Class: Gapic::CallOptions::RetryPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/gapic/call_options/retry_policy.rb

Overview

The policy for retrying failed RPC calls using an incremental backoff. A new object instance should be used for every RpcCall invocation.

Only errors orginating from GRPC will be retried.

Instance Method Summary collapse

Constructor Details

#initialize(retry_codes: nil, initial_delay: nil, multiplier: nil, max_delay: nil) ⇒ RetryPolicy

Create new API Call RetryPolicy.

Parameters:

  • initial_delay (Numeric) (defaults to: nil)

    client-side timeout

  • multiplier (Numeric) (defaults to: nil)

    client-side timeout

  • max_delay (Numeric) (defaults to: nil)

    client-side timeout



31
32
33
34
35
36
37
# File 'lib/gapic/call_options/retry_policy.rb', line 31

def initialize retry_codes: nil, initial_delay: nil, multiplier: nil, max_delay: nil
  @retry_codes   = convert_codes retry_codes
  @initial_delay = initial_delay
  @multiplier    = multiplier
  @max_delay     = max_delay
  @delay         = nil
end

Instance Method Details

#call(error) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/gapic/call_options/retry_policy.rb', line 61

def call error
  return false unless retry? error

  delay!
  increment_delay!

  true
end

#delayObject

The current delay value.



57
58
59
# File 'lib/gapic/call_options/retry_policy.rb', line 57

def delay
  @delay || initial_delay
end

#initial_delayObject



43
44
45
# File 'lib/gapic/call_options/retry_policy.rb', line 43

def initial_delay
  @initial_delay || 1
end

#max_delayObject



51
52
53
# File 'lib/gapic/call_options/retry_policy.rb', line 51

def max_delay
  @max_delay || 15
end

#multiplierObject



47
48
49
# File 'lib/gapic/call_options/retry_policy.rb', line 47

def multiplier
  @multiplier || 1.3
end

#retry_codesObject



39
40
41
# File 'lib/gapic/call_options/retry_policy.rb', line 39

def retry_codes
  @retry_codes || []
end