class Rookout::ComWs::Backoff

Public Class Methods

new() click to toggle source
# File lib/rookout/com_ws/backoff.rb, line 6
def initialize
  @connect_time = nil
  reset_backoff
end

Public Instance Methods

after_connect() click to toggle source
# File lib/rookout/com_ws/backoff.rb, line 19
def after_connect
  @connect_time = Time.now
end
after_disconnect() click to toggle source
# File lib/rookout/com_ws/backoff.rb, line 11
def after_disconnect
  reset_backoff if @connect_time && Time.new > @connect_time + Config.backoff_reset_time
  @connect_time = nil

  sleep @next_backoff
  @next_backoff = [@next_backoff * 2, Config.backoff_max_time].min
end

Private Instance Methods

reset_backoff() click to toggle source
# File lib/rookout/com_ws/backoff.rb, line 25
def reset_backoff
  @next_backoff = Config.backoff_factor
end