Class: EventHub::Heartbeat
- Inherits:
-
Object
- Object
- EventHub::Heartbeat
- Includes:
- Helper
- Defined in:
- lib/eventhub/heartbeat.rb
Instance Attribute Summary collapse
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
Instance Method Summary collapse
- #build_message(action = "running") ⇒ Object
-
#initialize(processor) ⇒ Heartbeat
constructor
A new instance of Heartbeat.
Methods included from Helper
#class_to_array, #duration, #format_string, #now_stamp
Constructor Details
#initialize(processor) ⇒ Heartbeat
Returns a new instance of Heartbeat.
8 9 10 11 12 |
# File 'lib/eventhub/heartbeat.rb', line 8 def initialize(processor) @started_at = Time.now @processor = processor @statistics = @processor.statistics end |
Instance Attribute Details
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
6 7 8 |
# File 'lib/eventhub/heartbeat.rb', line 6 def processor @processor end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
6 7 8 |
# File 'lib/eventhub/heartbeat.rb', line 6 def started_at @started_at end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
6 7 8 |
# File 'lib/eventhub/heartbeat.rb', line 6 def statistics @statistics end |
Instance Method Details
#build_message(action = "running") ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/eventhub/heartbeat.rb', line 15 def (action = "running") = ::EventHub::Message.new .origin_module_id = processor.name .origin_type = "processor" .origin_site_id = 'global' .process_name = 'event_hub.heartbeat' now = Time.now # message structure needs more changes .body = { version: processor.version, action: action, pid: Process.pid, process_name: 'event_hub.heartbeat', heartbeat: { started: now_stamp(started_at), stamp_last_beat: now_stamp(now), uptime_in_ms: (now - started_at)*1000, heartbeat_cycle_in_ms: processor.heartbeat_cycle_in_s * 1000, queues_consuming_from: processor.listener_queues, queues_publishing_to: ['event_hub.inbound'], # needs more dynamic in the future host: Socket.gethostname, addresses: addresses, messages: { total: statistics., successful: statistics., unsuccessful: statistics., average_size: statistics., average_process_time_in_ms: statistics.*1000, total_process_time_in_ms: statistics.*1000 } } } end |