beanstix v0.1.0 Beanstix
Beanstix - A beanstalkd client coding with Elixir
Forked from ElixirTalk Copyright 2014-2016 by jsvisa(delweng@gmail.com)
Link to this section 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.
Delete all jobs in a given tube
Put a job to the current tube.
Put a job in the specified tube.
The opts are the same as put
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.
Link to this section Types
put_options()
put_result()
put_result() ::
{:ok, job_id()} | {:error, Beanstix.Error.t() | connection_error() | binary()}
Link to this section Functions
bury(pid, id, opts \\ [])
bury(pid(), non_neg_integer(), [{:priority, integer()}]) :: {:ok, :buried | :not_found} | {:error, connection_error()}
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.
command(pid, command, timeout \\ 5000)
Connect to the beanstalkd server.
connect(host \\ '127.0.0.1', port \\ 11300, timeout \\ :infinity)
connect(:inet.ip_address() | :inet.hostname(), integer(), timeout()) :: {:ok, pid()} | {:error, term()}
delete(pid, id)
delete(pid(), job_id()) :: {:ok, :deleted | :not_found} | {:error, connection_error()}
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)
ignore(pid(), String.t()) :: {:ok, non_neg_integer() | :not_ignored} | {:error, connection_error()}
Remove the named tube from the watch list for the current connection.
kick(pid, bound \\ 1)
kick(pid(), non_neg_integer()) :: {:ok, non_neg_integer()} | {:error, connection_error()}
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)
kick_job(pid(), job_id()) :: {:ok, :not_found | :kicked} | {:error, connection_error()}
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)
list_tube_used(pid()) :: {:ok, String.t()} | {:error, connection_error()}
Return the tube currently being used by the client.
list_tubes(pid)
list_tubes(pid()) :: {:ok, list()} | {:error, connection_error()}
Return a list of all existing tubes in the server.
list_tubes_watched(pid)
list_tubes_watched(pid()) :: {:ok, list()} | {:error, connection_error()}
Return the tubes currently being watched by the client.
pause_tube(pid, tube, opts \\ [])
pause_tube(pid(), String.t(), [{:delay, integer()}]) :: {:ok, :paused | :not_found} | {:error, connection_error()}
Delay any new job being reserved for a given time.
peek(pid, id)
peek(pid(), job_id()) :: {:ok, job_id() | :not_found} | {:error, connection_error()}
Let the client inspect a job in the system. Peeking the given job id
peek_buried(pid)
peek_buried(pid()) :: {:ok, job_id() | :not_found} | {:error, connection_error()}
Peeking the next job in the list of buried jobs.
peek_delayed(pid)
peek_delayed(pid()) :: {:ok, job_id() | :not_found} | {:error, connection_error()}
Peeking the delayed job with the shortest delay left.
peek_ready(pid)
peek_ready(pid()) :: {:ok, job_id() | :not_found} | {:error, connection_error()}
Peeking the next ready job.
pipeline(pid, commands, timeout \\ 5000)
purge_tube(pid, tube)
Delete all jobs in a given tube
put(pid, data, opts \\ [])
put(pid(), String.t(), put_options()) :: put_result()
Put a job to the current tube.
The opts can be any combination of
:priority- 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:ttrseconds, 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.
put!(pid, data, opts \\ [])
put!(pid(), String.t(), put_options()) :: job_id()
put_in_tube(pid, tube, data, opts \\ [])
put_in_tube(pid(), String.t(), String.t(), put_options()) :: put_result()
Put a job in the specified tube.
The opts are the same as put
put_in_tube!(pid, tube, data, opts \\ [])
put_in_tube!(pid(), String.t(), String.t(), put_options()) :: job_id()
Close the connection to server.
release(pid, id, opts \\ [])
release(pid(), non_neg_integer(), priority: integer(), delay: integer()) :: {:ok, :released | :buried | :not_found} | {:error, connection_error()}
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
:priority- 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)
reserve(pid()) :: {:ok, {job_id(), String.t()}} | {:error, connection_error()}
Get a job from the currently watched tubes.
reserve(pid, timeout)
reserve(pid(), non_neg_integer()) :: {:ok, {job_id(), String.t()} | :deadline_soon | :timed_out} | {:error, connection_error()}
Get a job from the currently watched tubes with timeout of seconds.
Give statistical information about the system as a whole.
stats_job(pid, id)
stats_job(pid(), non_neg_integer()) :: {:ok, Map.t() | :not_found} | {:error, connection_error()}
Similar to stats/0, gives statistical information about the specified job if
it exists.
stats_tube(pid, tube)
stats_tube(pid(), String.t()) :: {:ok, Map.t() | :not_found} | {:error, connection_error()}
Similar to stats/0, gives statistical information about the specified tube
if it exists.
stats_tube!(pid, tube)
stats_tube!(pid(), String.t()) :: {:ok, Map.t() | :not_found} | {:error, connection_error()}
touch(pid, id)
touch(pid(), job_id()) :: {:ok, :touched | :not_found} | {:error, connection_error()}
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)
use(pid(), String.t()) :: {:ok, String.t()} | {:error, connection_error()}
Use a tube to put jobs.
watch(pid, tube)
watch(pid(), String.t()) :: {:ok, non_neg_integer()} | {:error, connection_error()}
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.