NAME
Gearman::Spawner::Client::Async - asynchronous Danga::Socket client for Gearman::Spawner::Worker workers
SYNOPSIS
$client = Gearman::Spawner::Client::Async->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,
});
METHODS
- Gearman::Spawner::Client::Async->new(%options)
-
Creates a new client object. Options:
- job_servers
-
(Required) Arrayref of servers to connect to.
- $client->run_method(%options)
-
Dispatches a foreground job to a worker. Options:
- class
-
(Required) The name of the worker class.
- method
-
(Required) The name of the method in class to call.
- success_cb
-
(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.
- error_cb
-
(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.
- data
-
(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.
- timeout
-
(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.
- unique
-
(Optional) The opaque unique tag for coalescing jobs.
- run_method_background
-
Dispatches a background job to a worker.
Options:
- class
-
(Required) The name of the worker class.
- method
-
(Required) The name of the method in class to call.
- data
-
(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.
- unique
-
(Optional) The opaque unique tag for coalescing jobs.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 42:
=over without closing =back