beanstalk-client 0.6.0 → 0.6.1
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 +5 -0
 - data/Manifest.txt +1 -0
 - data/lib/beanstalk-client.rb +0 -3
 - data/lib/beanstalk-client/connection.rb +15 -13
 - data/lib/beanstalk-client/errors.rb +33 -0
 - data/lib/beanstalk-client/version.rb +1 -1
 - data/website/index.html +1 -1
 - metadata +3 -2
 
    
        data/History.txt
    CHANGED
    
    
    
        data/Manifest.txt
    CHANGED
    
    
    
        data/lib/beanstalk-client.rb
    CHANGED
    
    
| 
         @@ -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  
     | 
| 
       220 
     | 
    
         
            -
                  pick_connection. 
     | 
| 
       221 
     | 
    
         
            -
                rescue  
     | 
| 
      
 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 
     | 
    
         
            -
                   
     | 
| 
       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 
     | 
    
         
            -
                   
     | 
| 
       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  
     | 
| 
      
 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
         
     | 
    
        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. 
     | 
| 
      
 36 
     | 
    
         
            +
                  <a href="http://rubyforge.org/projects/beanstalk" class="numbers">0.6.1</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.6. 
     | 
| 
       7 
     | 
    
         
            -
            date: 2008-01- 
     | 
| 
      
 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
         
     |