beanstalk-client 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/lib/beanstalk-client/connection.rb +26 -20
- data/lib/beanstalk-client/version.rb +1 -1
- data/website/index.html +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -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
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
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
|
342
|
-
|
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
|
346
|
-
|
351
|
+
def send_to_rand_conn(*args)
|
352
|
+
connect()
|
353
|
+
wrap{pick_connection.send(*args)}
|
347
354
|
end
|
348
355
|
|
349
|
-
def
|
350
|
-
|
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
|
354
|
-
(
|
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
|
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.
|
36
|
+
<a href="http://rubyforge.org/projects/beanstalk" class="numbers">0.11.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘beanstalk-client’</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.
|
7
|
-
date: 2008-04-
|
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
|