Class: Dionysus::Producer::Outbox::HealthCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/producer/outbox/health_check.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120) ⇒ HealthCheck

Returns a new instance of HealthCheck.



14
15
16
17
# File 'lib/dionysus/producer/outbox/health_check.rb', line 14

def initialize(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120)
  @hostname = hostname
  @expiry_time_in_seconds = expiry_time_in_seconds
end

Instance Attribute Details

#expiry_time_in_secondsObject (readonly)

Returns the value of attribute expiry_time_in_seconds.



12
13
14
# File 'lib/dionysus/producer/outbox/health_check.rb', line 12

def expiry_time_in_seconds
  @expiry_time_in_seconds
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



12
13
14
# File 'lib/dionysus/producer/outbox/health_check.rb', line 12

def hostname
  @hostname
end

Class Method Details

.check(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120) ⇒ Object



8
9
10
# File 'lib/dionysus/producer/outbox/health_check.rb', line 8

def self.check(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120)
  new(hostname: hostname, expiry_time_in_seconds: expiry_time_in_seconds).check
end

Instance Method Details

#checkObject



19
20
21
22
23
24
25
# File 'lib/dionysus/producer/outbox/health_check.rb', line 19

def check
  if healthcheck_storage.running?
    ""
  else
    "[Dionysus Producer Outbox healthcheck failed]"
  end
end

#register_heartbeatObject



27
28
29
# File 'lib/dionysus/producer/outbox/health_check.rb', line 27

def register_heartbeat
  healthcheck_storage.touch
end

#worker_stoppedObject



31
32
33
# File 'lib/dionysus/producer/outbox/health_check.rb', line 31

def worker_stopped
  healthcheck_storage.remove
end