Class: Profiler::Cluster::SlaveRegistry::Entry
- Inherits:
-
Struct
- Object
- Struct
- Profiler::Cluster::SlaveRegistry::Entry
- Defined in:
- lib/profiler/cluster/slave_registry.rb
Instance Attribute Summary collapse
-
#last_heartbeat_at ⇒ Object
Returns the value of attribute last_heartbeat_at.
-
#name ⇒ Object
Returns the value of attribute name.
-
#registered_at ⇒ Object
Returns the value of attribute registered_at.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
Instance Attribute Details
#last_heartbeat_at ⇒ Object
Returns the value of attribute last_heartbeat_at
8 9 10 |
# File 'lib/profiler/cluster/slave_registry.rb', line 8 def last_heartbeat_at @last_heartbeat_at end |
#name ⇒ Object
Returns the value of attribute name
8 9 10 |
# File 'lib/profiler/cluster/slave_registry.rb', line 8 def name @name end |
#registered_at ⇒ Object
Returns the value of attribute registered_at
8 9 10 |
# File 'lib/profiler/cluster/slave_registry.rb', line 8 def registered_at @registered_at end |
#url ⇒ Object
Returns the value of attribute url
8 9 10 |
# File 'lib/profiler/cluster/slave_registry.rb', line 8 def url @url end |
Instance Method Details
#status ⇒ Object
9 10 11 12 |
# File 'lib/profiler/cluster/slave_registry.rb', line 9 def status threshold = Profiler.configuration.cluster_offline_threshold (Time.now - last_heartbeat_at) < threshold ? "online" : "offline" end |
#to_h ⇒ Object
14 15 16 17 18 19 |
# File 'lib/profiler/cluster/slave_registry.rb', line 14 def to_h super.merge(status: status).tap do |h| h[:registered_at] = h[:registered_at]&.iso8601 h[:last_heartbeat_at] = h[:last_heartbeat_at]&.iso8601 end end |