Gearman::Spawner::Client::AnyEvent - asynchronous AnyEvent client for Gearman::Spawner::Worker workers
$client = Gearman::Spawner::Client::AnyEvent->new( job_servers => ['localhost:4730'] ); $client->run_method( class => 'MyWorker', method => 'sing', arg => [qw( do re mi )], success_cb => sub { my $result = shift; say "success! result is $result"; }, error_cb => sub { my $reason = shift; say "failed because $reason"; }, timeout => 3, });
Creates a new client object. Options:
(Required) Arrayref of servers to connect to.
Dispatches a foreground job to a worker. Options:
(Required) The name of the worker class.
(Required) The name of the method in class to call.
(Required) The coderef to be called when the job completes successfully. The first argument to it will be the deserialized result returned by the worker method.
(Required) The coderef to be called if the job does not complete. This may occur for several reasons, including but not limited to: the worker code threw an exception; the server did not respond before the timeout period; or the number of job retries was exceeded.
The first argument passed to error_cb is a string providing the best available information about the error.
(Optional) The job-specific data to pass to the worker. Any structure that can be serialized with Storable is allowed. If omitted, undef is sent.
(Optional) If the job has not completed or failed within this amount of time, error_cb will be called. Even if the job subsequently completes, success_cb will not be called.
(Optional) The opaque unique tag for coalescing jobs.
Dispatches a background job to a worker.
Options:
To install Gearman::Spawner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gearman::Spawner
CPAN shell
perl -MCPAN -e shell install Gearman::Spawner
For more information on module installation, please visit the detailed CPAN module installation guide.