class EventHub::ActorWatchdog

Watchdog class

Public Class Methods

new() click to toggle source
# File lib/eventhub/actor_watchdog.rb, line 9
def initialize
  EventHub.logger.info("Watchdog is starting...")
  async.start
end

Public Instance Methods

cleanup() click to toggle source
# File lib/eventhub/actor_watchdog.rb, line 21
def cleanup
  EventHub.logger.info("Watchdog is cleaning up...")
end
start() click to toggle source
# File lib/eventhub/actor_watchdog.rb, line 14
def start
  loop do
    watch
    sleep Configuration.processor[:watchdog_cycle_in_s]
  end
end

Private Instance Methods

watch() click to toggle source
# File lib/eventhub/actor_watchdog.rb, line 27
def watch
  connection = create_bunny_connection
  connection.start

  EventHub::Configuration.processor[:listener_queues].each do |queue_name|
    unless connection.queue_exists?(queue_name)
      EventHub.logger.warn("Queue [#{queue_name}] is missing")
      raise "Queue [#{queue_name}] is missing"
    end
  end
ensure
  connection&.close
end