Class: Profiler::Cluster::SlaveRegistry::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/profiler/cluster/slave_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_heartbeat_atObject

Returns the value of attribute last_heartbeat_at

Returns:

  • (Object)

    the current value of last_heartbeat_at



8
9
10
# File 'lib/profiler/cluster/slave_registry.rb', line 8

def last_heartbeat_at
  @last_heartbeat_at
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



8
9
10
# File 'lib/profiler/cluster/slave_registry.rb', line 8

def name
  @name
end

#registered_atObject

Returns the value of attribute registered_at

Returns:

  • (Object)

    the current value of registered_at



8
9
10
# File 'lib/profiler/cluster/slave_registry.rb', line 8

def registered_at
  @registered_at
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



8
9
10
# File 'lib/profiler/cluster/slave_registry.rb', line 8

def url
  @url
end

Instance Method Details

#statusObject



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_hObject



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