Sha256: b7b87232f14ff777e9b563e3e127fd66a183a7c666cc03d6e2b86e7af479b3fe
Contents?: true
Size: 661 Bytes
Versions: 13
Compression:
Stored size: 661 Bytes
Contents
module Kestrel class Client class Blocking < Proxy # random backoff sleeping SLEEP_TIMES = [[0] * 1, [0.01] * 2, [0.1] * 2, [0.5] * 2, [1.0] * 1].flatten def get(*args) count = 0 while count += 1 if response = client.get(*args) return response end sleep_for_count(count) end end def get_without_blocking(*args) client.get(*args) end private def sleep_for_count(count) base = SLEEP_TIMES[count] || SLEEP_TIMES.last time = ((rand * base) + base) / 2 sleep time if time > 0 end end end end
Version data entries
13 entries across 13 versions & 1 rubygems