Class: EventHub::ActorHeartbeat
- Inherits:
-
Object
- Object
- EventHub::ActorHeartbeat
- Includes:
- Celluloid, Helper
- Defined in:
- lib/eventhub/actor_heartbeat.rb
Overview
Heartbeat class
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(processor_instance) ⇒ ActorHeartbeat
constructor
A new instance of ActorHeartbeat.
- #start ⇒ Object
Methods included from Helper
#create_bunny_connection, #get_name_from_class, #now_stamp, #stringify_keys
Constructor Details
#initialize(processor_instance) ⇒ ActorHeartbeat
Returns a new instance of ActorHeartbeat.
9 10 11 12 |
# File 'lib/eventhub/actor_heartbeat.rb', line 9 def initialize(processor_instance) @processor_instance = processor_instance async.start end |
Instance Method Details
#cleanup ⇒ Object
27 28 29 30 31 |
# File 'lib/eventhub/actor_heartbeat.rb', line 27 def cleanup EventHub.logger.info("Heartbeat is cleaning up...") publish(heartbeat(action: "stopped")) EventHub.logger.info("Heartbeat has sent a [stopped] beat") end |
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/eventhub/actor_heartbeat.rb', line 14 def start EventHub.logger.info("Heartbeat is starting...") every(60 * 60 * 24) { EventHub.logger.info("Actual actors: #{Celluloid::Actor.all.size}: #{Celluloid::Actor.all.map { |a| a.class }.join(", ")}") } publish(heartbeat(action: "started")) EventHub.logger.info("Heartbeat has sent [started] beat") loop do sleep Configuration.processor[:heartbeat_cycle_in_s] publish(heartbeat) end end |