ElixirTalk v1.1.0 ElixirTalk

ElixirTalk - A beanstalkd client coding with Elixir

from Copyright 2014-2016 by jsvisa(delweng@gmail.com)

Summary

Functions

Put 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

Connect to the beanstalkd server

Remove 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

Remove the named tube from the watch list for the current connection

Move jobs into the ready queue. If there are any buried jobs, it will only kick buried jobs. Otherwise it will kick delayed jobs

Similar to kick(bound), if the given job id exists and is in a buried or delayed state, it will be moved to the ready queue of the the same tube where it currently belongs

Return the tube currently being used by the client

Return a list of all existing tubes in the server

Return the tubes currently being watched by the client

Delay any new job being reserved for a given time

Let the client inspect a job in the system. Peeking the given job id

Peeking the next job in the list of buried jobs

Peeking the delayed job with the shortest delay left

Peeking the next ready job

Put a job to the current tube

Close the connection to server

Put 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

Get a job from the currently watched tubes

Get a job from the currently watched tubes with timeout of seconds

Give statistical information about the system as a whole

Similar to stats/0, gives statistical information about the specified job if it exists

Similar to stats/0, gives statistical information about the specified tube if it exists

Allow 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

Use a tube to put jobs

Add 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

Types

result ::
  {:inserted, non_neg_integer} |
  {:buried, non_neg_integer} |
  {:expected_crlf} |
  :job_too_big |
  :darining

Functions

bury(pid, id, pri \\ 0)

Specs

bury(pid, non_neg_integer, non_neg_integer) ::
  :buried |
  :not_found

Put 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.

connect(opts)

Specs

connect(List.t) :: {:ok, pid} | {:error, term}

Connect to the beanstalkd server.

connect(host \\ '127.0.0.1', port \\ 11300, timeout \\ :infinity)

Specs

connect(:inet.ip_address | :inet.hostname, integer, integer) ::
  {:ok, pid} |
  {:error, term}
delete(pid, id)

Specs

delete(pid, non_neg_integer) :: :deleted | :not_found

Remove 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.

ignore(pid, tube)

Specs

ignore(pid, String.t) ::
  {:watching, non_neg_integer} |
  :not_ingored

Remove the named tube from the watch list for the current connection.

kick(pid, bound)

Specs

kick(pid, non_neg_integer) :: {:kicked, non_neg_integer}

Move jobs into the ready queue. If there are any buried jobs, it will only kick buried jobs. Otherwise it will kick delayed jobs.

Apply only to the currently used tube.

kick_job(pid, id)

Specs

kick_job(pid, non_neg_integer) :: :kicked | :not_found

Similar to kick(bound), if the given job id exists and is in a buried or delayed state, it will be moved to the ready queue of the the same tube where it currently belongs.

list_tube_used(pid)

Specs

list_tube_used(pid) :: {:using, String.t}

Return the tube currently being used by the client.

list_tubes(pid)

Specs

list_tubes(pid) :: List.t

Return a list of all existing tubes in the server.

list_tubes_watched(pid)

Specs

list_tubes_watched(pid) :: List.t

Return the tubes currently being watched by the client.

pause_tube(pid, tube, delay)

Specs

pause_tube(pid, String.t, non_neg_integer) ::
  :paused |
  :not_found

Delay any new job being reserved for a given time.

peek(pid, id)

Specs

peek(pid, non_neg_integer) ::
  {:found, non_neg_integer} |
  :not_found

Let the client inspect a job in the system. Peeking the given job id

peek_buried(pid)

Specs

peek_buried(pid) ::
  {:found, non_neg_integer} |
  :not_found

Peeking the next job in the list of buried jobs.

peek_delayed(pid)

Specs

peek_delayed(pid) ::
  {:found, non_neg_integer} |
  :not_found

Peeking the delayed job with the shortest delay left.

peek_ready(pid)

Specs

peek_ready(pid) ::
  {:found, non_neg_integer} |
  :not_found

Peeking the next ready job.

put(pid, data, opts \\ [])

Specs

put(pid, String.t, Keyword.t) :: result

Put a job to the current tube.

The opts can be any combination of

  • :pri - 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 - 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.
quit(pid)

Specs

quit(pid) :: :ok

Close the connection to server.

release(pid, id, opts \\ [])

Specs

release(pid, non_neg_integer, Keyword) ::
  :released |
  :buried |
  :not_found

Put 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.

The opts can any combination of

  • :pri - a new priority to assign to the job;

  • :delay - an integer number of seconds to wait before putting the job back in the ready queue. The job will be in the “delayed” state during this time.
reserve(pid)

Specs

reserve(pid) :: {:reserved, non_neg_integer, String.t}

Get a job from the currently watched tubes.

reserve(pid, timeout)

Specs

reserve(pid, non_neg_integer) ::
  {:reserved, non_neg_integer, {non_neg_integer, String.t}} |
  :deadline_soon |
  :timed_out

Get a job from the currently watched tubes with timeout of seconds.

stats(pid)

Specs

stats(pid) :: Keyword.t

Give statistical information about the system as a whole.

stats_job(pid, id)

Specs

stats_job(pid, non_neg_integer) ::
  Keyword.t |
  :not_found

Similar to stats/0, gives statistical information about the specified job if it exists.

stats_tube(pid, tube)

Specs

stats_tube(pid, String.t) :: Keyword.t | :not_found

Similar to stats/0, gives statistical information about the specified tube if it exists.

touch(pid, id)

Specs

touch(pid, non_neg_integer) :: :touched | :not_found

Allow 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.

use(pid, tube)

Specs

use(pid, String.t) :: {:using, String.t}

Use a tube to put jobs.

watch(pid, tube)

Specs

watch(pid, String.t) :: {:watcing, non_neg_integer}

Add 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.