Class: Rookout::ComWs::Backoff
- Inherits:
-
Object
- Object
- Rookout::ComWs::Backoff
- Defined in:
- lib/rookout/com_ws/backoff.rb
Instance Method Summary collapse
- #after_connect ⇒ Object
- #after_disconnect ⇒ Object
-
#initialize ⇒ Backoff
constructor
A new instance of Backoff.
Constructor Details
#initialize ⇒ Backoff
Returns a new instance of Backoff.
6 7 8 9 |
# File 'lib/rookout/com_ws/backoff.rb', line 6 def initialize @connect_time = nil reset_backoff end |
Instance Method Details
#after_connect ⇒ Object
19 20 21 |
# File 'lib/rookout/com_ws/backoff.rb', line 19 def after_connect @connect_time = Time.now end |
#after_disconnect ⇒ Object
11 12 13 14 15 16 17 |
# 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 |