NAME
Protocol::Gearman::Worker
- a simple synchronous Gearman worker binding
DESCRIPTION
A base class that implements a complete Gearman worker. This abstract class still requires the implementation methods as documented in Protocol::Gearman::Base, but otherwise provides a full set of behaviour useful to Gearman workers.
As it is based on Future it is suitable for both synchronous and asynchronous use. When backed by an implementation capable of performing asynchronously, this object fully supports asynchronous Gearman communication. When backed by a synchronous implementation, it will still yield Future
instances but the limitations of the synchronous implementation may limit how much concurrency and asynchronous behaviour can be acheived.
A simple concrete implementation suitable for synchronous use can be found in Protocol::Gearman::Worker::Connection.
METHODS
$worker->can_do( $name )
Informs the server that the worker can perform a function of the given name.
$worker->grab_job ==> $job
Returns a future that will eventually yield another job assignment from the server as an instance of a job object; see below.
JOB OBJECTS
Objects of this type are returned by the grab_job
method. They represent individual job assignments from the server, and can be used to obtain details of the work to perform, and report on its result.
$worker = $job->worker
Returns the Protocol::Gearman::Worker
object the job was received by.
$handle = $job->handle
Returns the job handle assigned by the server. Most implementations should not need to use this directly.
$func = $job->func
$arg = $job->arg
The function name and opaque argument data bytes sent by the requesting client.
$job->data( $data )
Sends more data back to the client. Intended for long-running jobs with incremental output.
$job->warning( $warning )
Sends a warning to the client.
$job->status( $numerator, $denominator )
Sets the current progress of the job.
$job->complete( $result )
Informs the server that the job is now complete, and sets its result.
$job->fail
Informs the server that the job has failed.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>