Class: MultipleMan::ChannelMaintenance::Reaper

Inherits:
Object
  • Object
show all
Defined in:
lib/multiple_man/channel_maintenance/reaper.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Reaper

Returns a new instance of Reaper.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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

Instance Method Details

#push(channel) ⇒ Object



22
23
24
# File 'lib/multiple_man/channel_maintenance/reaper.rb', line 22

def push(channel)
  queue << channel
end

#stopObject



26
27
28
29
# File 'lib/multiple_man/channel_maintenance/reaper.rb', line 26

def stop
  worker.kill
  worker.join
end