class Beanstalk::Tube

Overview

This class represents a Beanstalk tube.

Defined in:

beanstalk/tube.cr

Constant Summary

DEFAULT_QUEUE_NAME = "default"

Constant for the default tube name.

MAX_NAME_LEN = 200

Constant for the maximum tube name length.

VALID_NAME_PATTERN = /^[A-Za-z0-9_\-\+;\$\/\.\(\)]{1,200}$/

A constant for the valid name pattern.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(connection : Connection, name : String = DEFAULT_QUEUE_NAME) #

Constructor. Preferrably you should simple obtain your Tube instances from a Connection instance rather than direct instantiating them. Creates a Tube object set to use and watch the queue name passed in. If the queue name differs from the default then the Tube created will still be watching the default queue too.


[View source]

Class Method Detail

def self.valid_tube_name?(name : String) #

A method to check whether a given string is a valid tube name.


[View source]

Instance Method Detail

def bury(job : Job, priority : UInt32 = Job::Settings::DEFAULT_PRIORITY) #

Buries the specified job. Buried jobs are not part of the ready jobs list and therefore cannot be reserved. To unbury a job kick it.


[View source]
def bury(job_id, priority : UInt32 = Job::Settings::DEFAULT_PRIORITY) #

Buries the job by its id. Buried jobs are not part of the ready jobs list and therefore cannot be reserved. To unbury a job kick it.


[View source]
def connection : Beanstalk::Connection #

Retrieves the connection associated with the Tube.


[View source]
def delete(job_id : Int64 | Nil) #

Deletes a job from Beanstalk based on the job id. Returns true upon successful completion. Raises an exception if the job id is invalid.


[View source]
def delete(job : Job) #

Deletes a Job from Beanstalk. Note the Job passed in must have an id or an exception will be raised. Returns true upon successful completion.


[View source]
def delete?(job : Job) #

Attempts to delete the Job passed in. If the Job has no id then the method simply returns false, otherwise it makes a call to delete() using the specified job.


[View source]
def empty! #

This method will reserve and delete every job that it can from a Tube and will not return until it tries to reserve a job and receives nil back. This method returns the number of jobs deleted from the queue.


[View source]
def ignore(name : String) #

This method instructs a Tube to stop watching a named queue for content.


[View source]
def kick(maximum : UInt32) #

This method instructs the server to kick buried jobs to the ready queue. No more than maximum jobs will be kicked by the server. If you specify a maximum of zero then the method will automatical assume a maximum of one. If successful the method returns the actual number of jobs that were kicked.


[View source]
def kick_job(job : Job) #

This method instructs the server to kick a specific job from the buried state (if it is buried) to the ready state. The method returns a boolean to indicate whether the kick request was successful.


[View source]
def kick_job(job_id) #

This method instructs the server to kick a specific job from the buried state (if it is buried) to the ready state. The method returns a boolean to indicate whether the kick request was successful.


[View source]
def peek(state : JobState) #

Fetches details for a job, if one is available, without actually reserving it. Note that you must stipulate the state of the job you would like to peek at.


[View source]
def put(job : Job, settings : Job::Settings | Nil = nil) #

This method puts a Job into the queue currently being used by the Tube.


[View source]
def release(job_id : Int | String, settings : Job::Settings | Nil = nil) #

This method releases a Job that had previously been reserved, returning it to the ready list and making it available to be reserved again. Note that, if job settings are specified, only the priority and delay are set when the job is released.


[View source]
def release(job : Job, settings : Job::Settings | Nil = nil) #

This method releases a Job that had previously been reserved, returning it to the ready list and making it available to be reserved again. Note that, if job settings are specified, only the priority and delay are set when the job is released.


[View source]
def reserve(time_out : Time::Span) : Job | Nil #

Attempts to reserve a Job from a Tube. Takes an optional time_out parameter the indicates the mimimum number of seconds to wait for a Job to become available before giving up and returning nil.


[View source]
def reserve(job_id) #

Reserves a job from a Tube based on it's id. This method will raises an exception if the Job could not be found.


[View source]
def reserve : Job #

Attempts to reserve a job from a Tube, blocking until one becomes available.


[View source]
def reserve?(job_id) : Job | Nil #

Reserves a job from a Tube based on it's id. This method will return nil if the Job could not be found.


[View source]
def reserve? #

This method is equivalent to calling the reserve method with a time out of zero. It should return immediately with either a Job or nil.


[View source]
def stats(job_id : Int | String) #

This method fetches information relating to a specific job.


[View source]
def stats(job : Job) #

This method fetches information relating to a specific job.


[View source]
def stats #

This method fetches stats for the queue being used by a tube.


[View source]
def touch(job_id : Int | String) #

Touches the specified job, extending it's current time to run.


[View source]
def touch(job : Job) #

Touches the specified job, extending it's current time to run.


[View source]
def use(name : String) #

Instructs a Tube to use a given queue name, supplanting the previously used name. The queue name provided must be valid.


[View source]
def using : String #

Retrieves the name of the queue the Tube is using.


[View source]
def watch(name : String) #

Instructs a tube to watch a named queue for content. If the named queue does not exist it will be created.


[View source]
def watching : Array(String) #

Retrieves an array of the names of the queues the Tube is watching.


[View source]