class MultipleMan::ChannelMaintenance::Reaper

Attributes

config[R]
queue[R]
worker[R]

Public Class Methods

new(config) click to toggle source
# File lib/multiple_man/channel_maintenance/reaper.rb, line 4
def initialize(config)
  @config = config
  @queue = Queue.new

  @worker = Thread.new do
    loop do
      channel = queue.pop
      begin
        channel.close unless channel.closed?
        puts "Channel #{channel.number} closed!"
      rescue Bunny::Exception, Timeout::Error
        sleep config.connection_recovery[:time_between_retries]
        retry
      end
    end
  end
end

Public Instance Methods

push(channel) click to toggle source
# File lib/multiple_man/channel_maintenance/reaper.rb, line 22
def push(channel)
  queue << channel
end
stop() click to toggle source
# File lib/multiple_man/channel_maintenance/reaper.rb, line 26
def stop
  worker.kill
  worker.join
end