Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adds rdoc documentation for several methods

  • Loading branch information...
commit 3b2627d338b9a3f5361d59e24b57bd63dcac8c69 1 parent d39d9f7
@timcharper timcharper authored
View
8 README.txt
@@ -1 +1,7 @@
-README
+= README
+
+For more detail on what many of the commands do, see the beanstalkd protocol documentation:
+
+http://github.com/kr/beanstalkd/blob/master/doc/protocol.txt?raw=true
+
+
View
15 lib/beanstalk-client/connection.rb
@@ -265,14 +265,28 @@ def last_server
@last_conn.addr
end
+ # Put a job on the queue.
+ #
+ # == Parameters:
+ #
+ # * <tt>body</tt>: the payload of the job (use Beanstalk::Pool#yput / Beanstalk::Job#ybody to automatically serialize your payload with YAML)
+ # * <tt>pri</tt>: priority. Default 65536 (higher numbers are higher priority)
+ # * <tt>delay</tt>: how long to wait until making the job available for reservation
+ # * <tt>ttr</tt>: time in seconds for the job to reappear on the queue (if beanstalk doesn't hear from a consumer within this time, assume the consumer died and make the job available for someone else to process). Default 120 seconds.
def put(body, pri=65536, delay=0, ttr=120)
send_to_rand_conn(:put, body, pri, delay, ttr)
end
+ # Like put, but serialize the object with YAML.
def yput(obj, pri=65536, delay=0, ttr=120)
send_to_rand_conn(:yput, obj, pri, delay, ttr)
end
+ # Reserve a job from the queue.
+ #
+ # == Parameters
+ #
+ # * <tt>timeout</tt> - Time (in seconds) to wait for a job to be available. If nil, wait indefinitely.
def reserve(timeout=nil)
send_to_rand_conn(:reserve, timeout)
end
@@ -325,6 +339,7 @@ def remove(conn)
@connections.delete(conn.addr)
end
+ # Close all open connections for this pool
def close
while @connections.size > 0
addr = @connections.keys.last
View
6 lib/beanstalk-client/job.rb
@@ -43,16 +43,19 @@ def initialize(conn, id, body, reserved=true)
@reserved = reserved
end
+ # Deletes the job from the queue
def delete()
return if !@reserved
@conn.delete(id)
@reserved = false
end
+
def put_back(pri=self.pri, delay=0, ttr=self.ttr)
@conn.put(body, pri, delay, ttr)
end
+ # Releases the job back to the queue so another consumer can get it (call this if the job failed and want it to be tried again)
def release(newpri=nil, delay=0)
return if !@reserved
@conn.release(id, newpri || pri, delay)
@@ -65,6 +68,7 @@ def bury(newpri=nil)
@reserved = false
end
+ # Ping beanstalkd to to tell it you're alive and processing. If beanstalkd doesn't hear from you for more than the ttr seconds (specified by the put command), then it assumes the consumer died and reinserts the job back into the queue for another to process.
def touch
return if !@reserved
@conn.touch(id)
@@ -75,6 +79,8 @@ def stats()
end
def timeouts() stats['timeouts'] end
+
+ # Time left (in seconds) that beanstalk has to process the job. When this time expires, beanstalkd automatically reinserts the job in the queue. See the ttr parameter for Beanstalk::Pool#put
def time_left() stats['time-left'] end
def age() stats['age'] end
def state() stats['state'] end
Please sign in to comment.
Something went wrong with that request. Please try again.