Class: Temporalio::RetryPolicy

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

Overview

Options for retrying workflows and activities.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(initial_interval: 1.0, backoff_coefficient: 2.0, max_interval: nil, max_attempts: 0, non_retryable_error_types: nil) ⇒ RetryPolicy

Create retry policy.



47
48
49
50
51
52
53
54
55
# File 'lib/temporalio/retry_policy.rb', line 47

def initialize(
  initial_interval: 1.0,
  backoff_coefficient: 2.0,
  max_interval: nil,
  max_attempts: 0,
  non_retryable_error_types: nil
)
  super
end

Instance Attribute Details

#backoff_coefficientFloat



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/temporalio/retry_policy.rb', line 26

class RetryPolicy
  # @!visibility private
  def self._from_proto(raw_policy)
    RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.initial_interval) || raise, # Never nil
      backoff_coefficient: raw_policy.backoff_coefficient,
      max_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.maximum_interval),
      max_attempts: raw_policy.maximum_attempts,
      non_retryable_error_types: raw_policy.non_retryable_error_types&.to_a
    )
  end

  # Create retry policy.
  #
  # @param initial_interval [Float] Backoff interval in seconds for the first retry. Default 1.0.
  # @param backoff_coefficient [Float] Coefficient to multiply previous backoff interval by to get new interval.
  #   Default 2.0.
  # @param max_interval [Float, nil] Maximum backoff interval in seconds between retries. Default 100x
  #   `initial_interval`.
  # @param max_attempts [Integer] Maximum number of attempts. If `0`, the default, there is no maximum.
  # @param non_retryable_error_types [Array<String>, nil] List of error types that are not retryable.
  def initialize(
    initial_interval: 1.0,
    backoff_coefficient: 2.0,
    max_interval: nil,
    max_attempts: 0,
    non_retryable_error_types: nil
  )
    super
  end

  # @!visibility private
  def _to_proto
    raise 'Initial interval cannot be negative' if initial_interval.negative?
    raise 'Backoff coefficient cannot be less than 1' if backoff_coefficient < 1
    raise 'Max interval cannot be negative' if max_interval&.negative?
    raise 'Max interval cannot be less than initial interval' if max_interval && max_interval < initial_interval
    raise 'Max attempts cannot be negative' if max_attempts.negative?

    Api::Common::V1::RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.seconds_to_duration(initial_interval),
      backoff_coefficient:,
      maximum_interval: Internal::ProtoUtils.seconds_to_duration(max_interval),
      maximum_attempts: max_attempts,
      non_retryable_error_types:
    )
  end
end

#initial_intervalFloat



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/temporalio/retry_policy.rb', line 26

class RetryPolicy
  # @!visibility private
  def self._from_proto(raw_policy)
    RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.initial_interval) || raise, # Never nil
      backoff_coefficient: raw_policy.backoff_coefficient,
      max_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.maximum_interval),
      max_attempts: raw_policy.maximum_attempts,
      non_retryable_error_types: raw_policy.non_retryable_error_types&.to_a
    )
  end

  # Create retry policy.
  #
  # @param initial_interval [Float] Backoff interval in seconds for the first retry. Default 1.0.
  # @param backoff_coefficient [Float] Coefficient to multiply previous backoff interval by to get new interval.
  #   Default 2.0.
  # @param max_interval [Float, nil] Maximum backoff interval in seconds between retries. Default 100x
  #   `initial_interval`.
  # @param max_attempts [Integer] Maximum number of attempts. If `0`, the default, there is no maximum.
  # @param non_retryable_error_types [Array<String>, nil] List of error types that are not retryable.
  def initialize(
    initial_interval: 1.0,
    backoff_coefficient: 2.0,
    max_interval: nil,
    max_attempts: 0,
    non_retryable_error_types: nil
  )
    super
  end

  # @!visibility private
  def _to_proto
    raise 'Initial interval cannot be negative' if initial_interval.negative?
    raise 'Backoff coefficient cannot be less than 1' if backoff_coefficient < 1
    raise 'Max interval cannot be negative' if max_interval&.negative?
    raise 'Max interval cannot be less than initial interval' if max_interval && max_interval < initial_interval
    raise 'Max attempts cannot be negative' if max_attempts.negative?

    Api::Common::V1::RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.seconds_to_duration(initial_interval),
      backoff_coefficient:,
      maximum_interval: Internal::ProtoUtils.seconds_to_duration(max_interval),
      maximum_attempts: max_attempts,
      non_retryable_error_types:
    )
  end
end

#max_attemptsInteger



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/temporalio/retry_policy.rb', line 26

class RetryPolicy
  # @!visibility private
  def self._from_proto(raw_policy)
    RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.initial_interval) || raise, # Never nil
      backoff_coefficient: raw_policy.backoff_coefficient,
      max_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.maximum_interval),
      max_attempts: raw_policy.maximum_attempts,
      non_retryable_error_types: raw_policy.non_retryable_error_types&.to_a
    )
  end

  # Create retry policy.
  #
  # @param initial_interval [Float] Backoff interval in seconds for the first retry. Default 1.0.
  # @param backoff_coefficient [Float] Coefficient to multiply previous backoff interval by to get new interval.
  #   Default 2.0.
  # @param max_interval [Float, nil] Maximum backoff interval in seconds between retries. Default 100x
  #   `initial_interval`.
  # @param max_attempts [Integer] Maximum number of attempts. If `0`, the default, there is no maximum.
  # @param non_retryable_error_types [Array<String>, nil] List of error types that are not retryable.
  def initialize(
    initial_interval: 1.0,
    backoff_coefficient: 2.0,
    max_interval: nil,
    max_attempts: 0,
    non_retryable_error_types: nil
  )
    super
  end

  # @!visibility private
  def _to_proto
    raise 'Initial interval cannot be negative' if initial_interval.negative?
    raise 'Backoff coefficient cannot be less than 1' if backoff_coefficient < 1
    raise 'Max interval cannot be negative' if max_interval&.negative?
    raise 'Max interval cannot be less than initial interval' if max_interval && max_interval < initial_interval
    raise 'Max attempts cannot be negative' if max_attempts.negative?

    Api::Common::V1::RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.seconds_to_duration(initial_interval),
      backoff_coefficient:,
      maximum_interval: Internal::ProtoUtils.seconds_to_duration(max_interval),
      maximum_attempts: max_attempts,
      non_retryable_error_types:
    )
  end
end

#max_intervalFloat?



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/temporalio/retry_policy.rb', line 26

class RetryPolicy
  # @!visibility private
  def self._from_proto(raw_policy)
    RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.initial_interval) || raise, # Never nil
      backoff_coefficient: raw_policy.backoff_coefficient,
      max_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.maximum_interval),
      max_attempts: raw_policy.maximum_attempts,
      non_retryable_error_types: raw_policy.non_retryable_error_types&.to_a
    )
  end

  # Create retry policy.
  #
  # @param initial_interval [Float] Backoff interval in seconds for the first retry. Default 1.0.
  # @param backoff_coefficient [Float] Coefficient to multiply previous backoff interval by to get new interval.
  #   Default 2.0.
  # @param max_interval [Float, nil] Maximum backoff interval in seconds between retries. Default 100x
  #   `initial_interval`.
  # @param max_attempts [Integer] Maximum number of attempts. If `0`, the default, there is no maximum.
  # @param non_retryable_error_types [Array<String>, nil] List of error types that are not retryable.
  def initialize(
    initial_interval: 1.0,
    backoff_coefficient: 2.0,
    max_interval: nil,
    max_attempts: 0,
    non_retryable_error_types: nil
  )
    super
  end

  # @!visibility private
  def _to_proto
    raise 'Initial interval cannot be negative' if initial_interval.negative?
    raise 'Backoff coefficient cannot be less than 1' if backoff_coefficient < 1
    raise 'Max interval cannot be negative' if max_interval&.negative?
    raise 'Max interval cannot be less than initial interval' if max_interval && max_interval < initial_interval
    raise 'Max attempts cannot be negative' if max_attempts.negative?

    Api::Common::V1::RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.seconds_to_duration(initial_interval),
      backoff_coefficient:,
      maximum_interval: Internal::ProtoUtils.seconds_to_duration(max_interval),
      maximum_attempts: max_attempts,
      non_retryable_error_types:
    )
  end
end

#non_retryable_error_typesArray<String>?



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/temporalio/retry_policy.rb', line 26

class RetryPolicy
  # @!visibility private
  def self._from_proto(raw_policy)
    RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.initial_interval) || raise, # Never nil
      backoff_coefficient: raw_policy.backoff_coefficient,
      max_interval: Internal::ProtoUtils.duration_to_seconds(raw_policy.maximum_interval),
      max_attempts: raw_policy.maximum_attempts,
      non_retryable_error_types: raw_policy.non_retryable_error_types&.to_a
    )
  end

  # Create retry policy.
  #
  # @param initial_interval [Float] Backoff interval in seconds for the first retry. Default 1.0.
  # @param backoff_coefficient [Float] Coefficient to multiply previous backoff interval by to get new interval.
  #   Default 2.0.
  # @param max_interval [Float, nil] Maximum backoff interval in seconds between retries. Default 100x
  #   `initial_interval`.
  # @param max_attempts [Integer] Maximum number of attempts. If `0`, the default, there is no maximum.
  # @param non_retryable_error_types [Array<String>, nil] List of error types that are not retryable.
  def initialize(
    initial_interval: 1.0,
    backoff_coefficient: 2.0,
    max_interval: nil,
    max_attempts: 0,
    non_retryable_error_types: nil
  )
    super
  end

  # @!visibility private
  def _to_proto
    raise 'Initial interval cannot be negative' if initial_interval.negative?
    raise 'Backoff coefficient cannot be less than 1' if backoff_coefficient < 1
    raise 'Max interval cannot be negative' if max_interval&.negative?
    raise 'Max interval cannot be less than initial interval' if max_interval && max_interval < initial_interval
    raise 'Max attempts cannot be negative' if max_attempts.negative?

    Api::Common::V1::RetryPolicy.new(
      initial_interval: Internal::ProtoUtils.seconds_to_duration(initial_interval),
      backoff_coefficient:,
      maximum_interval: Internal::ProtoUtils.seconds_to_duration(max_interval),
      maximum_attempts: max_attempts,
      non_retryable_error_types:
    )
  end
end