Class: Cadence::RetryPolicy

Inherits:
Struct
  • Object
show all
Defined in:
lib/cadence/retry_policy.rb

Defined Under Namespace

Classes: InvalidRetryPolicy

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#backoffObject

Returns the value of attribute backoff

Returns:

  • (Object)

    the current value of backoff



4
5
6
# File 'lib/cadence/retry_policy.rb', line 4

def backoff
  @backoff
end

#expiration_intervalObject

Returns the value of attribute expiration_interval

Returns:

  • (Object)

    the current value of expiration_interval



4
5
6
# File 'lib/cadence/retry_policy.rb', line 4

def expiration_interval
  @expiration_interval
end

#intervalObject

Returns the value of attribute interval

Returns:

  • (Object)

    the current value of interval



4
5
6
# File 'lib/cadence/retry_policy.rb', line 4

def interval
  @interval
end

#max_attemptsObject

Returns the value of attribute max_attempts

Returns:

  • (Object)

    the current value of max_attempts



4
5
6
# File 'lib/cadence/retry_policy.rb', line 4

def max_attempts
  @max_attempts
end

#max_intervalObject

Returns the value of attribute max_interval

Returns:

  • (Object)

    the current value of max_interval



4
5
6
# File 'lib/cadence/retry_policy.rb', line 4

def max_interval
  @max_interval
end

#non_retriable_errorsObject

Returns the value of attribute non_retriable_errors

Returns:

  • (Object)

    the current value of non_retriable_errors



4
5
6
# File 'lib/cadence/retry_policy.rb', line 4

def non_retriable_errors
  @non_retriable_errors
end

Instance Method Details

#validate!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cadence/retry_policy.rb', line 9

def validate!
  unless interval && backoff
    raise InvalidRetryPolicy, 'interval and backoff must be set'
  end

  unless max_attempts || expiration_interval
    raise InvalidRetryPolicy, 'max_attempts or expiration_interval must be set'
  end

  unless [interval, max_interval, expiration_interval].compact.all? { |arg| arg.is_a?(Integer) }
    raise InvalidRetryPolicy, 'All intervals must be specified in whole seconds'
  end

  unless [interval, max_interval, expiration_interval].compact.all? { |arg| arg > 0 }
    raise InvalidRetryPolicy, 'All intervals must be greater than 0'
  end
end