class Beanstalk::Tube

Overview

This class represents a Beanstalk tube.

Defined in:

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.


Class Method Detail

def self.valid_tube_name?(name : String) #

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


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.


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.


def connection : Beanstalk::Connection #

Retrieves the connection associated with the Tube.


def delete(job_id : Int64?) #

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


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.


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.


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.


def ignore(name : String) #

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


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.


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.


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.


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.


def put(job : Job, settings : Job::Settings? = nil) #

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


def release(job_id : Int | String, settings : Job::Settings? = 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.


def release(job : Job, settings : Job::Settings? = 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.


def reserve(time_out : Time::Span) : Job? #

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.


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.


def reserve : Job #

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


def reserve?(job_id) : Job? #

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


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.


def stats(job_id : Int | String) #

This method fetches information relating to a specific job.


def stats(job : Job) #

This method fetches information relating to a specific job.


def stats #

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


def touch(job_id : Int | String) #

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


def touch(job : Job) #

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


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.


def using : String #

Retrieves the name of the queue the Tube is using.


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.


def watching : Array(String) #

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