Beanstalk\
Pool
¶Description: | Beanstalkd connection pool |
---|---|
Author: | Joshua Dechant <jdechant@shapeup.com> |
$beanstalk = (new \Beanstalk\Pool)
->addServer('localhost', 11300)
->useTube('my-tube');
$beanstalk->put('Hello World!');
Class Methods
Pool::addServer
– Add a beanstalkd server to the poolPool::close
– Close all connections in the poolPool::connect
– Establish a connection to all servers in the poolPool::getConnections
Pool::getLastConnection
Pool::getServers
– Get the Beanstalkd server addresses in the poolPool::getTimeout
– Get the current connection timeoutPool::ignoreTube
– Ignore commandPool::kick
– Kick commandPool::listTubes
– The list-tubes command returns a list of all existing tubesPool::pauseTube
– The pause-tube command can delay any new job being reserved for a given timePool::put
– The “put” command is for any process that wants to insert a job into the queuePool::reserve
– Reserve commandPool::setStream
– Sets the stream class to use for the connections in the poolPool::setTimeout
– Set the connection timeout for attempting to connect to servers in the poolPool::stats
– The stats command gives statistical information about the system as a wholePool::useTube
– Use commandPool::watchTube
– Watch commandBeanstalk\Pool::
addServer
($host[, $port = 11300])¶Description: | Add a beanstalkd server to the pool |
---|---|
Parameters: |
|
Returns: | self |
Beanstalk\Pool::
close
()¶Description: | Close all connections in the pool |
---|
Beanstalk\Pool::
connect
()¶Description: | Establish a connection to all servers in the pool |
---|
Beanstalk\Pool::
getConnections
()¶Beanstalk\Pool::
getLastConnection
()¶Beanstalk\Pool::
getServers
()¶Description: | Get the Beanstalkd server addresses in the pool |
---|---|
Returns: | array Beanstalkd server addresses in the format “host:port” |
Beanstalk\Pool::
getTimeout
()¶Description: | Get the current connection timeout |
---|---|
Returns: | float Current connection timeout |
Beanstalk\Pool::
ignoreTube
($tube)¶Description: | Ignore command |
---|---|
Parameters: |
|
Returns: | self |
The “ignore” command is for consumers. It removes the named tube from the watch list for the current connection.
Beanstalk\Pool::
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\Pool::
listTubes
()¶Description: | The list-tubes command returns a list of all existing tubes |
---|
Beanstalk\Pool::
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\Pool::
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\Pool::
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\Pool::
setStream
($class)¶Description: | Sets the stream class to use for the connections in the pool |
---|---|
Parameters: |
|
Returns: | self |
Beanstalk\Pool::
setTimeout
($timeout)¶Description: | Set the connection timeout for attempting to connect to servers in the pool |
---|---|
Parameters: |
|
Returns: | self |
Beanstalk\Pool::
stats
()¶Description: | The stats command gives statistical information about the system as a whole |
---|
Beanstalk\Pool::
useTube
($tube)¶Description: | Use command |
---|---|
Parameters: |
|
Returns: | self |
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\Pool::
watchTube
($tube)¶Description: | Watch command |
---|---|
Parameters: |
|
Returns: | self |
The “watch” command adds the named tube to the watch list for the connection pool. 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”.