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
#bunny_connection_properties, #get_name_from_class, #now_stamp
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 |
# File 'lib/eventhub/actor_heartbeat.rb', line 27 def cleanup EventHub.logger.info('Heartbeat is cleanig up...') publish(heartbeat(action: 'stopped')) 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) { EventHub.logger.info("Running actors: #{Celluloid::Actor.all.size}: #{Celluloid::Actor.all.map{ |a| a.class }.join(', ') }") } publish(heartbeat(action: 'started')) loop do sleep Configuration.processor[:heartbeat_cycle_in_s] EventHub.logger.info('Running heartbeat...') publish(heartbeat) end end |