beanstalk-client 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.11.0 2008-04-17
2
+
3
+ * Fix an infinite loop bug when the server goes away.
4
+
1
5
  == 0.10.0 2008-04-11
2
6
 
3
7
  * Some optimizations to avoid sending unnecessary use and watch commands.
@@ -209,6 +209,7 @@ module Beanstalk
209
209
 
210
210
  def method_missing(selector, *args, &block)
211
211
  begin
212
+ @multi.last_conn = @conn
212
213
  @conn.send(selector, *args, &block)
213
214
  rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, UnexpectedResponse => ex
214
215
  @multi.remove(@conn)
@@ -218,6 +219,8 @@ module Beanstalk
218
219
  end
219
220
 
220
221
  class Pool
222
+ attr_accessor :last_conn
223
+
221
224
  def initialize(addrs)
222
225
  @addrs = addrs
223
226
  connect()
@@ -330,40 +333,43 @@ module Beanstalk
330
333
 
331
334
  private
332
335
 
333
- def send_to_each_conn_first_res(sel, *args)
334
- open_connections.each do |c|
335
- x = wrap(c, sel, *args)
336
- return x if x
337
- end
338
- nil
336
+ def wrap(*args)
337
+ yield
338
+ rescue DrainingError
339
+ # Don't reconnect -- we're not interested in this server
340
+ retry
341
+ rescue EOFError, Errno::ECONNRESET, Errno::EPIPE
342
+ connect()
343
+ retry
339
344
  end
340
345
 
341
- def send_to_rand_conn(sel, *args)
342
- wrap(pick_connection, sel, *args)
346
+ def send_to_each_conn_first_res(*args)
347
+ connect()
348
+ wrap{open_connections.inject(nil) {|r,c| r or c.send(*args)}}
343
349
  end
344
350
 
345
- def send_to_all_conns(sel, *args)
346
- compact_hash(make_hash(@connections.map{|a, c| [a, wrap(c, sel, *args)]}))
351
+ def send_to_rand_conn(*args)
352
+ connect()
353
+ wrap{pick_connection.send(*args)}
347
354
  end
348
355
 
349
- def pick_connection()
350
- open_connections[rand(open_connections.size)] or raise NotConnected
356
+ def send_to_all_conns(*args)
357
+ connect()
358
+ wrap{compact_hash(map_hash(@connections){|c| c.send(*args)})}
351
359
  end
352
360
 
353
- def wrap(conn, sel, *args)
354
- (@last_conn = conn).send(sel, *args)
355
- rescue DrainingError
356
- # Don't reconnect -- we're not interested in this server
357
- retry
358
- rescue EOFError, Errno::ECONNRESET, Errno::EPIPE
359
- connect()
360
- retry
361
+ def pick_connection()
362
+ open_connections[rand(open_connections.size)] or raise NotConnected
361
363
  end
362
364
 
363
365
  def make_hash(pairs)
364
366
  Hash[*pairs.inject([]){|a,b|a+b}]
365
367
  end
366
368
 
369
+ def map_hash(h)
370
+ make_hash(h.map{|k,v| [k, yield(v)]})
371
+ end
372
+
367
373
  def compact_hash(hash)
368
374
  hash.reject{|k,v| v == nil}
369
375
  end
@@ -1,5 +1,5 @@
1
1
  module Beanstalk #:nodoc:
2
2
  module VERSION #:nodoc:
3
- STRING = '0.10.0'
3
+ STRING = '0.11.0'
4
4
  end
5
5
  end
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>Beanstalk Client</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/beanstalk"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/beanstalk" class="numbers">0.10.0</a>
36
+ <a href="http://rubyforge.org/projects/beanstalk" class="numbers">0.11.0</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;beanstalk-client&#8217;</h1>
39
39
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: beanstalk-client
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.10.0
7
- date: 2008-04-11 00:00:00 -07:00
6
+ version: 0.11.0
7
+ date: 2008-04-17 00:00:00 -07:00
8
8
  summary: Ruby client library for the Beanstalk protocol
9
9
  require_paths:
10
10
  - lib