Beanstalk\
Connection
¶Description: | Beanstalkd connection |
---|---|
Author: | Joshua Dechant <jdechant@shapeup.com> |
Class Methods
Connection::__construct
– Constructor; establishes connection streamConnection::bury
– Bury commandConnection::close
– Close the connectionConnection::connect
– Connect to the beanstalkd serverConnection::delete
– Delete commandConnection::getServer
– Get the Beanstalkd server addressConnection::getStream
– Get the connect’s streamConnection::getTimeout
– Get the connection timeoutConnection::ignoreTube
– Ignore commandConnection::isTimedOut
– Has the connection timed out?Connection::kick
– Kick commandConnection::listTubes
– The list-tubes command returns a list of all existing tubesConnection::pauseTube
– The pause-tube command can delay any new job being reserved for a given timeConnection::peek
– Return job $idConnection::peekBuried
– Return the next job in the list of buried jobsConnection::peekDelayed
– Return the delayed job with the shortest delay leftConnection::peekReady
– Return the next ready jobConnection::put
– The “put” command is for any process that wants to insert a job into the queueConnection::release
– Release commandConnection::reserve
– Reserve commandConnection::setTimeout
– Set the connection timeoutConnection::stats
– The stats command gives statistical information about the system as a whole.Connection::statsJob
– The stats-job command gives statistical information about the specified job if it exists.Connection::statsTube
– The stats-tube command gives statistical information about the specified tube if it exists.Connection::touch
– Touch commandConnection::useTube
– Use commandConnection::validateResponse
– Generic validation for all responses from beanstalkdConnection::watchTube
– Watch commandBeanstalk\Connection::
__construct
($address, $stream[, $timeout = 500])¶Description: | Constructor; establishes connection stream |
---|---|
Parameters: |
|
Throws: | BeanstalkException When a connection cannot be established |
Beanstalk\Connection::
bury
($id, $priority)¶Description: | Bury command |
---|---|
Parameters: |
|
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.
Beanstalk\Connection::
close
()¶Description: | Close the connection |
---|
Beanstalk\Connection::
connect
()¶Description: | Connect to the beanstalkd server |
---|---|
Returns: | boolean |
Throws: | BeanstalkException When a connection cannot be established |
Beanstalk\Connection::
delete
($id)¶Description: | Delete command |
---|---|
Parameters: |
|
Returns: | boolean |
Throws: | BeanstalkException |
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, and jobs that are buried.
Beanstalk\Connection::
getServer
()¶Description: | Get the Beanstalkd server address |
---|---|
Returns: | string Beanstalkd server address in the format “host:port” |
Beanstalk\Connection::
getStream
()¶Description: | Get the connect’s stream |
---|---|
Returns: | BeanstalkConnectionStream |
Beanstalk\Connection::
getTimeout
()¶Description: | Get the connection timeout |
---|---|
Returns: | float Connection timeout |
Beanstalk\Connection::
ignoreTube
($tube)¶Description: | Ignore command |
---|---|
Parameters: |
|
The “ignore” command is for consumers. It removes the named tube from the watch list for the current connection.
Beanstalk\Connection::
isTimedOut
()¶Description: | Has the connection timed out? |
---|---|
Returns: | boolean |
Beanstalk\Connection::
kick
($bound)¶Description: | Kick command |
---|---|
Parameters: |
|
Returns: | integer The number of jobs actually kicked |
The kick command applies only to the currently used tube. It moves jobs into the ready queue. If there are any buried jobs, it will only kick buried jobs. Otherwise it will kick delayed jobs
Beanstalk\Connection::
listTubes
()¶Description: | The list-tubes command returns a list of all existing tubes |
---|
Beanstalk\Connection::
pauseTube
($tube, $delay)¶Description: | The pause-tube command can delay any new job being reserved for a given time |
---|---|
Parameters: |
|
Returns: | boolean |
Throws: | BeanstalkException |
Beanstalk\Connection::
peek
($id)¶Description: | Return job $id |
---|---|
Parameters: |
|
Returns: | BeanstalkJob |
Throws: | BeanstalkException When job cannot be found |
Beanstalk\Connection::
peekBuried
()¶Description: | Return the next job in the list of buried jobs |
---|---|
Returns: | BeanstalkJob |
Throws: | BeanstalkException When no jobs in buried state |
Beanstalk\Connection::
peekDelayed
()¶Description: | Return the delayed job with the shortest delay left |
---|---|
Returns: | BeanstalkJob |
Throws: | BeanstalkException When no jobs in delayed state |
Beanstalk\Connection::
peekReady
()¶Description: | Return the next ready job |
---|---|
Returns: | BeanstalkJob |
Throws: | BeanstalkException When no jobs in ready state |
Beanstalk\Connection::
put
($message[, $priority = 65536, $delay = 0, $ttr = 120])¶Description: | The “put” command is for any process that wants to insert a job into the queue |
---|---|
Parameters: |
|
Beanstalk\Connection::
release
($id, $priority, $delay)¶Description: | Release command |
---|---|
Parameters: |
|
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.
Beanstalk\Connection::
reserve
([$timeout = null])¶Description: | Reserve command |
---|---|
Parameters: |
|
This will return a newly-reserved job. If no job is available to be reserved, beanstalkd will wait to send a response until one becomes available. Once a job is reserved for the client, the client has limited time to run (TTR) the job before the job times out. When the job times out, the server will put the job back into the ready queue. Both the TTR and the actual time left can be found in response to the stats-job command.
A timeout value of 0 will cause the server to immediately return either a response or TIMED_OUT. A positive value of timeout will limit the amount of time the client will block on the reserve request until a job becomes available.
Beanstalk\Connection::
setTimeout
($timeout)¶Description: | Set the connection timeout |
---|---|
Parameters: |
|
Beanstalk\Connection::
stats
()¶Description: | The stats command gives statistical information about the system as a whole. |
---|
Beanstalk\Connection::
statsJob
($id)¶Description: | The stats-job command gives statistical information about the specified job if it exists. |
---|---|
Parameters: |
|
Returns: | BeanstalkStats |
Throws: | BeanstalkException When the job does not exist |
Beanstalk\Connection::
statsTube
($tube)¶Description: | The stats-tube command gives statistical information about the specified tube if it exists. |
---|---|
Parameters: |
|
Returns: | BeanstalkStats |
Throws: | BeanstalkException When the tube does not exist |
Beanstalk\Connection::
touch
($id)¶Description: | Touch command |
---|---|
Parameters: |
|
Returns: | boolean |
Throws: | BeanstalkException |
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).
Beanstalk\Connection::
useTube
($tube)¶Description: | Use command |
---|---|
Parameters: |
|
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”.
Beanstalk\Connection::
validateResponse
($response)¶Description: | Generic validation for all responses from beanstalkd |
---|---|
Parameters: |
|
Returns: | boolean true when response is valid |
Throws: | BeanstalkException When response is invalid |
Beanstalk\Connection::
watchTube
($tube)¶Description: | Watch command |
---|---|
Parameters: |
|
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”.