Skip to content

Commit

Permalink
Preserve the watch list for new pool connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Rarick committed Apr 25, 2008
1 parent a13decd commit 5a78a64
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/beanstalk-client/connection.rb
Expand Up @@ -223,6 +223,7 @@ class Pool

def initialize(addrs)
@addrs = addrs
@watch_list = ['default']
connect()
end

Expand All @@ -233,6 +234,10 @@ def connect()
if !@connections.include?(addr)
puts "connecting to beanstalk at #{addr}"
@connections[addr] = CleanupWrapper.new(addr, self)
prev_watched = @connections[addr].list_tubes_watched()
to_ignore = prev_watched - @watch_list
@watch_list.each{|tube| @connections[addr].watch(tube)}
to_ignore.each{|tube| @connections[addr].ignore(tube)}
end
rescue Exception => ex
puts "#{ex.class}: #{ex}"
Expand Down Expand Up @@ -267,11 +272,15 @@ def use(tube)
end

def watch(tube)
send_to_all_conns(:watch, tube)
r = send_to_all_conns(:watch, tube)
@watch_list = send_to_rand_conn(:list_tubes_watched)
return r
end

def ignore(tube)
send_to_all_conns(:ignore, tube)
r = send_to_all_conns(:ignore, tube)
@watch_list = send_to_rand_conn(:list_tubes_watched)
return r
end

def raw_stats()
Expand Down

0 comments on commit 5a78a64

Please sign in to comment.