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.
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 |
#delay ⇒ Object
The current delay value.
57 58 59 |
# File 'lib/gapic/call_options/retry_policy.rb', line 57 def delay @delay || initial_delay end |
#initial_delay ⇒ Object
43 44 45 |
# File 'lib/gapic/call_options/retry_policy.rb', line 43 def initial_delay @initial_delay || 1 end |
#max_delay ⇒ Object
51 52 53 |
# File 'lib/gapic/call_options/retry_policy.rb', line 51 def max_delay @max_delay || 15 end |
#multiplier ⇒ Object
47 48 49 |
# File 'lib/gapic/call_options/retry_policy.rb', line 47 def multiplier @multiplier || 1.3 end |
#retry_codes ⇒ Object
39 40 41 |
# File 'lib/gapic/call_options/retry_policy.rb', line 39 def retry_codes @retry_codes || [] end |