Class Phalcon\Queue\Beanstalk¶
Class to access the beanstalk queue service. Partially implements the protocol version 1.2
<?php
use Phalcon\Queue\Beanstalk;
$queue = new Beanstalk(
[
"host" => "127.0.0.1",
"port" => 11300,
"persistent" => true,
]
);
Constants¶
integer DEFAULT_DELAY
integer DEFAULT_PRIORITY
integer DEFAULT_TTR
string DEFAULT_TUBE
string DEFAULT_HOST
integer DEFAULT_PORT
Methods¶
public __construct ([array $parameters])
public connect ()
Makes a connection to the Beanstalkd server
public put (mixed $data, [array $options])
Puts a job on the queue using specified tube.
public reserve ([mixed $timeout])
Reserves/locks a ready job from the specified tube.
public choose (mixed $tube)
Change the active tube. By default the tube is "default".
public watch (mixed $tube)
The watch command adds the named tube to the watch list for the current connection.
public ignore (mixed $tube)
It removes the named tube from the watch list for the current connection.
public pauseTube (mixed $tube, mixed $delay)
Can delay any new job being reserved for a given time.
public kick (mixed $bound)
The kick command applies only to the currently used tube.
public stats ()
Gives statistical information about the system as a whole.
public statsTube (mixed $tube)
Gives statistical information about the specified tube if it exists.
public listTubes ()
Returns a list of all existing tubes.
public listTubeUsed ()
Returns the tube currently being used by the client.
public listTubesWatched ()
Returns a list tubes currently being watched by the client.
public peekReady ()
Inspect the next ready job.
public peekBuried ()
Return the next job in the list of buried jobs.
public peekDelayed ()
Return the next job in the list of buried jobs.
public jobPeek (mixed $id)
The peek commands let the client inspect a job in the system.
final public readStatus ()
Reads the latest status from the Beanstalkd server
final public readYaml ()
Fetch a YAML payload from the Beanstalkd server
public read ([mixed $length])
Reads a packet from the socket. Prior to reading from the socket will check for availability of the connection.
public write (mixed $data)
Writes data to the socket. Performs a connection if none is available
public disconnect ()
Closes the connection to the beanstalk server.
public quit ()
Simply closes the connection.
Class Phalcon\Queue\Beanstalk\Exception¶
extends class Phalcon\Exception
implements Throwable
Methods¶
final private Exception __clone () inherited from Exception
Clone the exception
public __construct ([mixed $message], [mixed $code], [mixed $previous]) inherited from Exception
Exception constructor
public __wakeup () inherited from Exception
...
final public string getMessage () inherited from Exception
Gets the Exception message
final public int getCode () inherited from Exception
Gets the Exception code
final public string getFile () inherited from Exception
Gets the file in which the exception occurred
final public int getLine () inherited from Exception
Gets the line in which the exception occurred
final public array getTrace () inherited from Exception
Gets the stack trace
final public Exception getPrevious () inherited from Exception
Returns previous Exception
final public Exception getTraceAsString () inherited from Exception
Gets the stack trace as a string
public string __toString () inherited from Exception
String representation of the exception
Class Phalcon\Queue\Beanstalk\Job¶
Represents a job in a beanstalk queue
Methods¶
public getId ()
public getBody ()
public __construct (Phalcon\Queue\Beanstalk $queue, mixed $id, mixed $body)
public delete ()
Removes a job from the server entirely
public release ([mixed $priority], [mixed $delay])
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.
public bury ([mixed $priority])
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.
public touch ()
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.
public kick ()
Move the job to the ready queue if it is delayed or buried.
public stats ()
Gives statistical information about the specified job if it exists.
public __wakeup ()
Checks if the job has been modified after unserializing the object