Sha256: 1f95b2d0e5b26b8b4f3a881e16b4375327a14f71aa33d8d46f5fdaeafe67ec21
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true class RailsTransactionalOutbox class HealthCheck KEY_PREFIX = "__rails_transactional__outbox_worker__running__" TMP_DIR = "/tmp" private_constant :KEY_PREFIX, :TMP_DIR 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 attr_reader :hostname, :expiry_time_in_seconds def initialize(hostname: ENV.fetch("HOSTNAME", nil), expiry_time_in_seconds: 120) @hostname = hostname @expiry_time_in_seconds = expiry_time_in_seconds end def check if healthcheck_storage.running? "" else "[Rails Transactional Outbox Worker healthcheck failed]" end end def register_heartbeat healthcheck_storage.touch end def worker_stopped healthcheck_storage.remove end private def healthcheck_storage @healthcheck_storage ||= FileBasedHealthcheck.new(directory: TMP_DIR, filename: key, time_threshold: expiry_time_in_seconds) end def key "#{KEY_PREFIX}#{hostname}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems