Class: Gapic::CallOptions::RetryPolicy
- Inherits:
-
Object
- Object
- Gapic::CallOptions::RetryPolicy
- 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
- #call(error) ⇒ Object
-
#delay ⇒ Object
The current delay value.
- #initial_delay ⇒ Object
-
#initialize(retry_codes: nil, initial_delay: nil, multiplier: nil, max_delay: nil) ⇒ RetryPolicy
constructor
Create new API Call RetryPolicy.
- #max_delay ⇒ Object
- #multiplier ⇒ Object
- #retry_codes ⇒ Object
Constructor Details
#initialize(retry_codes: nil, initial_delay: nil, multiplier: nil, max_delay: nil) ⇒ RetryPolicy
Create new API Call RetryPolicy.
33 34 35 36 37 38 39 |
# File 'lib/gapic/call_options/retry_policy.rb', line 33 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
63 64 65 66 67 68 69 70 |
# File 'lib/gapic/call_options/retry_policy.rb', line 63 def call error return false unless retry? error delay! increment_delay! true end |
#delay ⇒ Object
The current delay value.
59 60 61 |
# File 'lib/gapic/call_options/retry_policy.rb', line 59 def delay @delay || initial_delay end |
#initial_delay ⇒ Object
45 46 47 |
# File 'lib/gapic/call_options/retry_policy.rb', line 45 def initial_delay @initial_delay || 1 end |
#max_delay ⇒ Object
53 54 55 |
# File 'lib/gapic/call_options/retry_policy.rb', line 53 def max_delay @max_delay || 15 end |
#multiplier ⇒ Object
49 50 51 |
# File 'lib/gapic/call_options/retry_policy.rb', line 49 def multiplier @multiplier || 1.3 end |
#retry_codes ⇒ Object
41 42 43 |
# File 'lib/gapic/call_options/retry_policy.rb', line 41 def retry_codes @retry_codes || [] end |