Class: Bosh::Agent::HeartbeatProcessor
- Defined in:
- lib/bosh_agent/heartbeat_processor.rb
Constant Summary collapse
- MAX_OUTSTANDING_HEARTBEATS =
2
Instance Method Summary collapse
Instance Method Details
#beat ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bosh_agent/heartbeat_processor.rb', line 31 def beat raise HeartbeatError, "#{@pending} outstanding heartbeat(s)" if @pending > MAX_OUTSTANDING_HEARTBEATS Heartbeat.new.send_via_mbus do @pending -= 1 end @pending += 1 rescue => e Config.logger.warn("Error sending heartbeat: #{e}") Config.logger.warn(e.backtrace.join("\n")) raise e if @pending > MAX_OUTSTANDING_HEARTBEATS end |
#disable ⇒ Object
25 26 27 28 29 |
# File 'lib/bosh_agent/heartbeat_processor.rb', line 25 def disable Config.logger.info("Disabled heartbeats") @timer.cancel if @timer @timer = nil end |
#enable(interval) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bosh_agent/heartbeat_processor.rb', line 8 def enable(interval) unless EM.reactor_running? raise Bosh::Agent::HeartbeatError, "Event loop must be running in order to enable heartbeats" end if @timer Config.logger.warn("Heartbeat timer already running, canceling") disable end @pending = 0 @timer = EM.add_periodic_timer(interval) do beat end end |