Struct tokio_beanstalkd::Beanstalkd[][src]

pub struct Beanstalkd { /* fields omitted */ }

Connection to the Beanstalkd server.

All interactions with Beanstalkd happen by calling methods on a Beanstalkd instance.

Even though there is a quit command, Beanstalkd consideres a closed connection as the end of communication, so just dropping this struct will close the connection.

Methods

impl Beanstalkd
[src]

Connect to a Beanstalkd instance.

A successful TCP connect is considered the start of communication.

The "put" command is for any process that wants to insert a job into the queue.

It inserts a job into the client's currently used tube (see the use command below).

  • priority is an integer < 2**32. Jobs with smaller priority values will be scheduled before jobs with larger priorities. The most urgent priority is 0; the least urgent priority is 4,294,967,295.
  • delay is an integer number of seconds to wait before putting the job in the ready queue. The job will be in the "delayed" state during this time.
  • ttr -- time to run -- is an integer number of seconds to allow a worker to run this job. This time is counted from the moment a worker reserves this job. If the worker does not delete, release, or bury the job within ttr seconds, the job will time out and the server will release the job. The minimum ttr is 1. If the client sends 0, the server will silently increase the ttr to 1.
  • data is the job body -- a sequence of bytes of length from the previous line.

After sending the command line and body, the client waits for a reply, which is the integer id of the new job.

Reserve a job to process.

A process that wants to consume jobs from the queue uses reserve, delete, release, and bury.

The "use" command is for producers. Subsequent put commands will put jobs into the tube specified by this command. If no use command has been issued, jobs will be put into the tube named "default".

  • tube is a name at most 200 bytes. It specifies the tube to use. If the tube does not exist, it will be created.

The delete command removes a job from the server entirely. It is normally used by the client when the job has successfully run to completion. A client can delete jobs that it has reserved, ready jobs, delayed jobs, and jobs that are buried.

  • id is the job id to delete.

The release command puts a reserved job back into the ready queue (and marks its state as "ready") to be run by any client. It is normally used when the job fails because of a transitory error.

  • id is the job id to release.

  • pri is a new priority to assign to the job.

  • delay is an integer number of seconds to wait before putting the job in the ready queue. The job will be in the "delayed" state during this time.

The "touch" command allows a worker to request more time to work on a job. This is useful for jobs that potentially take a long time, but you still want the benefits of a TTR pulling a job away from an unresponsive worker. A worker may periodically tell the server that it's still alive and processing a job (e.g. it may do this on DEADLINE_SOON). The command postpones the auto release of a reserved job until TTR seconds from when the command is issued.

  • id is the ID of a job reserved by the current connection.

The bury command puts a job into the "buried" state. Buried jobs are put into a FIFO linked list and will not be touched by the server again until a client kicks them with the "kick" command.

  • id is the job id to release.

  • prioritiy is a new priority to assign to the job.

The "watch" command adds the named tube to the watch list for the current connection. A reserve command will take a job from any of the tubes in the watch list. For each new connection, the watch list initially consists of one tube, named "default".

  • is a name at most 200 bytes. It specifies a tube to add to the watch list. If the tube doesn't exist, it will be created.

The value returned is the count of the tubes being watched by the current connection.

The "ignore" command is for consumers. It removes the named tube from the watch list for the current connection.

  • is a name at most 200 bytes. It specifies a tube to add to the watch list. If the tube doesn't exist, it will be created.

A successful response is:

  • The count of the number of tubes currently watching

Trait Implementations

impl Debug for Beanstalkd
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Beanstalkd

impl Sync for Beanstalkd