Sha256: 5b1c530b3e0aa6d4620b30471eca94f057b541df34d298ce544f4ef7b78cb820
Contents?: true
Size: 630 Bytes
Versions: 2
Compression:
Stored size: 630 Bytes
Contents
module Dynamoid module Config module BackoffStrategies # Truncated binary exponential backoff algorithm # See https://en.wikipedia.org/wiki/Exponential_backoff class ExponentialBackoff def self.call(opts = {}) opts = { base_backoff: 0.5, ceiling: 3 }.merge(opts) base_backoff = opts[:base_backoff] ceiling = opts[:ceiling] times = 1 lambda do power = [times - 1, ceiling - 1].min backoff = base_backoff * (2 ** power) sleep backoff times += 1 end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dynamoid-2.2.0 | lib/dynamoid/config/backoff_strategies/exponential_backoff.rb |
dynamoid-2.1.0 | lib/dynamoid/config/backoff_strategies/exponential_backoff.rb |