- JOB OBJECTS
Protocol::Gearman::Worker - implement a Gearman worker
A base class that implements a complete Gearman worker. This abstract class still requires the implementation methods as documented in Protocol::Gearman, 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 Net::Gearman::Worker.
Informs the server that the worker can perform a function of the given name.
The following named options are recognised:
- timeout => INT
If specified, the function is registered using the
CAN_DO_TIMEOUTvariant, which sets a timeout on the Gearman server after which the function ought to have completed. The timeout is specified in seconds.
Returns a future that will eventually yield another job assignment from the server as an instance of a job object; see below.
Invoked by the
fail methods on a job object, after the server has been informed of the final status of the job. By default this method does nothing, but it is provided for subclasses to override, to be informed when a job is finished.
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.
Protocol::Gearman::Worker object the job was received by.
Returns the job handle assigned by the server. Most implementations should not need to use this directly.
The function name and opaque argument data bytes sent by the requesting client.
Sends more data back to the client. Intended for long-running jobs with incremental output.
Sends a warning to the client.
Sets the current progress of the job.
Informs the server that the job is now complete, and sets its result.
Informs the server that the job has failed.
Optionally an exception value can be supplied; if given this will be sent to the server using a
WORK_EXCEPTION message. Note that not all clients will receive this; it is an optional feature.
Paul Evans <email@example.com>