Sha256: fb20a56f8babab7f9efb6a9d7e927d647c25453f21bce83ad0da503d2cf7aa64

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require_relative "exponential_backoff"

module Retriable
  class Config
    ATTRIBUTES = ExponentialBackoff::ATTRIBUTES + [
      :sleep_disabled,
      :max_elapsed_time,
      :intervals,
      :timeout,
      :on,
      :on_retry,
      :contexts,
    ].freeze

    attr_accessor(*ATTRIBUTES)

    def initialize(opts = {})
      backoff = ExponentialBackoff.new

      @tries            = backoff.tries
      @base_interval    = backoff.base_interval
      @max_interval     = backoff.max_interval
      @rand_factor      = backoff.rand_factor
      @multiplier       = backoff.multiplier
      @sleep_disabled   = false
      @max_elapsed_time = 900 # 15 min
      @intervals        = nil
      @timeout          = nil
      @on               = [StandardError]
      @on_retry         = nil
      @contexts         = {}

      opts.each do |k, v|
        raise ArgumentError, "#{k} is not a valid option" if !ATTRIBUTES.include?(k)
        instance_variable_set(:"@#{k}", v)
      end
    end

    def to_h
      ATTRIBUTES.each_with_object({}) do |key, hash|
        hash[key] = public_send(key)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/retriable-3.1.2/lib/retriable/config.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/retriable-3.1.2/lib/retriable/config.rb
retriable-3.1.2 lib/retriable/config.rb