Class: RailsTransactionalOutbox::HealthCheck
- Inherits:
-
Object
- Object
- RailsTransactionalOutbox::HealthCheck
- Defined in:
- lib/rails_transactional_outbox/health_check.rb
Instance Attribute Summary collapse
-
#expiry_time_in_seconds ⇒ Object
readonly
Returns the value of attribute expiry_time_in_seconds.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120) ⇒ HealthCheck
constructor
A new instance of HealthCheck.
- #register_heartbeat ⇒ Object
- #worker_stopped ⇒ Object
Constructor Details
#initialize(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120) ⇒ HealthCheck
Returns a new instance of HealthCheck.
15 16 17 18 |
# File 'lib/rails_transactional_outbox/health_check.rb', line 15 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_seconds ⇒ Object (readonly)
Returns the value of attribute expiry_time_in_seconds.
13 14 15 |
# File 'lib/rails_transactional_outbox/health_check.rb', line 13 def expiry_time_in_seconds @expiry_time_in_seconds end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
13 14 15 |
# File 'lib/rails_transactional_outbox/health_check.rb', line 13 def hostname @hostname end |
Class Method Details
.check(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120) ⇒ Object
9 10 11 |
# File 'lib/rails_transactional_outbox/health_check.rb', line 9 def self.check(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120) new(hostname:, expiry_time_in_seconds:).check end |
Instance Method Details
#check ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rails_transactional_outbox/health_check.rb', line 20 def check if healthcheck_storage.running? "" else "[Rails Transactional Outbox Worker healthcheck failed]" end end |
#register_heartbeat ⇒ Object
28 29 30 |
# File 'lib/rails_transactional_outbox/health_check.rb', line 28 def register_heartbeat healthcheck_storage.touch end |
#worker_stopped ⇒ Object
32 33 34 |
# File 'lib/rails_transactional_outbox/health_check.rb', line 32 def worker_stopped healthcheck_storage.remove end |