beanstalk-client 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.6.1 2008-01-22
2
+
3
+ * More useful behavior when we lose the connection or the server is in drain
4
+ mode.
5
+
1
6
  == 0.6.0 2008-01-04
2
7
 
3
8
  * Protocol updates. Works with beanstalkd 0.6.
data/Manifest.txt CHANGED
@@ -8,6 +8,7 @@ config/requirements.rb
8
8
  lib/beanstalk-client.rb
9
9
  lib/beanstalk-client/bag.rb
10
10
  lib/beanstalk-client/connection.rb
11
+ lib/beanstalk-client/errors.rb
11
12
  lib/beanstalk-client/job.rb
12
13
  lib/beanstalk-client/version.rb
13
14
  log/debug.log
@@ -21,9 +21,6 @@ module Beanstalk
21
21
  extend self
22
22
 
23
23
  attr_accessor :select
24
-
25
- class UnexpectedResponse < RuntimeError
26
- end
27
24
  end
28
25
 
29
26
  require 'beanstalk-client/connection'
@@ -19,6 +19,7 @@ require 'socket'
19
19
  require 'fcntl'
20
20
  require 'yaml'
21
21
  require 'beanstalk-client/bag'
22
+ require 'beanstalk-client/errors'
22
23
  require 'beanstalk-client/job'
23
24
 
24
25
  module Beanstalk
@@ -183,7 +184,7 @@ module Beanstalk
183
184
  def method_missing(selector, *args, &block)
184
185
  begin
185
186
  @conn.send(selector, *args, &block)
186
- rescue EOFError, Errno::ECONNRESET => ex
187
+ rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, UnexpectedResponse => ex
187
188
  @multi.remove(@conn)
188
189
  raise ex
189
190
  end
@@ -216,25 +217,26 @@ module Beanstalk
216
217
  @connections.values()
217
218
  end
218
219
 
219
- def put(body, pri=65536, delay=0, ttr=120)
220
- pick_connection.put(body, pri, delay, ttr)
221
- rescue EOFError, Errno::ECONNRESET
220
+ def send_to_conn(sel, *args)
221
+ pick_connection.send(sel, *args)
222
+ rescue DrainingError
223
+ # Don't reconnect -- we're not interested in this server
224
+ retry
225
+ rescue EOFError, Errno::ECONNRESET, Errno::EPIPE
222
226
  connect()
223
227
  retry
224
228
  end
225
229
 
230
+ def put(body, pri=65536, delay=0, ttr=120)
231
+ send_to_conn(:put, body, pri, delay, ttr)
232
+ end
233
+
226
234
  def yput(obj, pri=65536, delay=0, ttr=120)
227
- pick_connection.yput(obj, pri, delay, ttr)
228
- rescue EOFError, Errno::ECONNRESET
229
- connect()
230
- retry
235
+ send_to_conn(:yput, obj, pri, delay, ttr)
231
236
  end
232
237
 
233
238
  def reserve()
234
- pick_connection.reserve()
235
- rescue EOFError, Errno::ECONNRESET
236
- connect()
237
- retry
239
+ send_to_conn(:reserve)
238
240
  end
239
241
 
240
242
  def raw_stats()
@@ -260,7 +262,7 @@ module Beanstalk
260
262
  private
261
263
 
262
264
  def pick_connection()
263
- open_connections[rand(open_connections.size)] or raise 'not connected'
265
+ open_connections[rand(open_connections.size)] or raise NotConnected
264
266
  end
265
267
  end
266
268
  end
@@ -0,0 +1,33 @@
1
+ # beanstalk-client/errors.rb - client library for beanstalk
2
+
3
+ # Copyright (C) 2007 Philotic Inc.
4
+
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ module Beanstalk
19
+ class NotConnected < RuntimeError
20
+ end
21
+
22
+ class UnexpectedResponse < RuntimeError
23
+ def self.new(word)
24
+ if self == UnexpectedResponse and word == 'DRAINING'
25
+ return DrainingError.new(nil)
26
+ end
27
+ super(word)
28
+ end
29
+ end
30
+
31
+ class DrainingError < UnexpectedResponse
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  module Beanstalk #:nodoc:
2
2
  module VERSION #:nodoc:
3
- STRING = '0.6.0'
3
+ STRING = '0.6.1'
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.6.0</a>
36
+ <a href="http://rubyforge.org/projects/beanstalk" class="numbers">0.6.1</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.6.0
7
- date: 2008-01-04 00:00:00 -08:00
6
+ version: 0.6.1
7
+ date: 2008-01-22 00:00:00 -08:00
8
8
  summary: Ruby client library for the Beanstalk protocol
9
9
  require_paths:
10
10
  - lib
@@ -39,6 +39,7 @@ files:
39
39
  - lib/beanstalk-client.rb
40
40
  - lib/beanstalk-client/bag.rb
41
41
  - lib/beanstalk-client/connection.rb
42
+ - lib/beanstalk-client/errors.rb
42
43
  - lib/beanstalk-client/job.rb
43
44
  - lib/beanstalk-client/version.rb
44
45
  - log/debug.log