Sha256: 026b84b28879285a663d170b96af914b40ee80d874758d4e5dd47013801c676d

Contents?: true

Size: 358 Bytes

Versions: 12

Compression:

Stored size: 358 Bytes

Contents

module Prefab
  class ExponentialBackoff
    def initialize(max_delay:, initial_delay: 2, multiplier: 2)
      @initial_delay = initial_delay
      @max_delay = max_delay
      @multiplier = multiplier
      @delay = initial_delay
    end

    def call
      delay = @delay
      @delay = [@delay * @multiplier, @max_delay].min
      delay
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
prefab-cloud-ruby-0.24.5 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.24.4 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.24.3 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.24.2 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.24.1 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.24.0 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.23.8 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.23.7 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.23.6 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.23.5 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.23.4 lib/prefab/exponential_backoff.rb
prefab-cloud-ruby-0.23.3 lib/prefab/exponential_backoff.rb