Class: Gapic::Operation::RetryPolicy

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

Overview

The policy for retrying operation reloads using an incremental backoff. A new object instance should be used for every Operation invocation.

Instance Method Summary collapse

Constructor Details

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

Create new Operation 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

  • timeout (Numeric) (defaults to: nil)

    client-side timeout



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

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

Instance Method Details

#callObject



54
55
56
57
58
59
60
61
# File 'lib/gapic/operation/retry_policy.rb', line 54

def call
  return unless retry?

  delay!
  increment_delay!

  true
end

#initial_delayObject



38
39
40
# File 'lib/gapic/operation/retry_policy.rb', line 38

def initial_delay
  @initial_delay || 10
end

#max_delayObject



46
47
48
# File 'lib/gapic/operation/retry_policy.rb', line 46

def max_delay
  @max_delay || 300 # Five minutes
end

#multiplierObject



42
43
44
# File 'lib/gapic/operation/retry_policy.rb', line 42

def multiplier
  @multiplier || 1.3
end

#timeoutObject



50
51
52
# File 'lib/gapic/operation/retry_policy.rb', line 50

def timeout
  @timeout || 3600 # One hour
end