NAME
Protocol::Gearman::Base
- abstract base class for both client and worker
DESCRIPTION
This base class is used by both Protocol::Gearman::Client and Protocol::Gearman::Worker. It shouldn't be used directly by end-user implementations. It is documented here largely to explain what methods an end implementation needs to provide, in order to create a Gearman client or worker.
PROVIDED METHODS
$base->pack_send_packet( $typename, @args )
Packs a packet from a list of arguments then sends it; a combination of Protocol::Gearman::pack_packet
and Protocol::Gearman::build_packet
. Uses the implementation's send
method.
$base->on_read( $buffer )
The implementation should call this method on receipt of more bytes of data. It parses and unpacks packets from the buffer, then dispatches to the appropriately named on_*
method. A combination of Protocol::Gearman::parse_packet
and Protocol::Gearman::unpack_packet
.
The $buffer
scalar may be modified; if it still contains bytes left over after the call these should be preserved by the implementation for the next time it is called.
$connection->on_ERROR( $name, $message )
Default handler for the TYPE_ERROR
packet. This method should be overriden by subclasses to change the behaviour.
REQUIRED METHODS
The implementation should provide the following methods:
$f = $base->new_future
Return a new Future subclass instance, for request methods to use. This instance should support awaiting appropriately.
$base->send( $bytes )
Send the given bytes to the server.
$base->on_TYPE( @args )
Invoked on receipt of the given type of packet. The exact packet types requried differs for clients or worker connections.
$h = $base->gearman_state
Return a HASH reference for the Gearman-related code to store its state on. If not implemented, a default method will be provided which uses $base
itself, for the common case of HASH-based methods.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>