Class: Legion::Extensions::Node::Transport::Messages::Beat

Inherits:
Transport::Message
  • Object
show all
Defined in:
lib/legion/extensions/node/transport/messages/beat.rb

Constant Summary collapse

BOOT_TIME =
::Process.clock_gettime(::Process::CLOCK_MONOTONIC)

Instance Method Summary collapse

Instance Method Details

#encrypt?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/legion/extensions/node/transport/messages/beat.rb', line 22

def encrypt?
  false
end

#expirationObject



18
19
20
# File 'lib/legion/extensions/node/transport/messages/beat.rb', line 18

def expiration
  5000
end

#messageObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/legion/extensions/node/transport/messages/beat.rb', line 26

def message
  hash = {
    name:      Legion::Settings[:client][:name],
    pid:       ::Process.pid,
    timestamp: Time.now,
    status:    @options[:status].nil? ? 'healthy' : @options[:status]
  }
  hash[:version] = Legion::VERSION if defined?(Legion::VERSION)
  hash[:metrics] = collect_metrics
  hash[:hosted_worker_ids] = collect_worker_ids
  hash[:rabbitmq_cluster] = collect_rabbitmq_cluster
  hash
end

#routing_keyObject



10
11
12
# File 'lib/legion/extensions/node/transport/messages/beat.rb', line 10

def routing_key
  'status'
end

#typeObject



14
15
16
# File 'lib/legion/extensions/node/transport/messages/beat.rb', line 14

def type
  'heartbeat'
end

#validateObject



40
41
42
43
44
# File 'lib/legion/extensions/node/transport/messages/beat.rb', line 40

def validate
  raise 'status should be a string' unless @options[:status].is_a?(String) || @options[:status].nil?

  @valid = true
end