Gearman::XS::Client - Perl client for gearman using libgearman
use Gearman::XS qw(:constants); use Gearman::XS::Client; $client = new Gearman::XS::Client; $ret = $client->add_server($host, $port); if ($ret != GEARMAN_SUCCESS) { printf(STDERR "%s\n", $client->error()); exit(1); } # single client interface ($ret, $result) = $client->do("reverse", 'teststring'); if ($ret == GEARMAN_SUCCESS) { printf("Result=%s\n", $result); } # background client interface ($ret, $job_handle) = $client->do_background('reverse', 'teststring); if ($ret != GEARMAN_SUCCESS) { printf(STDERR "%s\n", $client->error()); exit(1); } # concurrent client interface ($ret, $task) = $client->add_task('reverse', 'test1'); ($ret, $task) = $client->add_task('reverse', 'test2'); $ret = $client->run_tasks();
Gearman::XS::Client is a client class for the Gearman distributed job system using libgearman.
Returns a Gearman::XS::Client object.
Add a job server to a client. This goes into a list of servers than can be used to run tasks. No socket I/O happens here, it is just added to a list. Returns a standard gearman return value.
Add a list of job servers to a client. The format for the server list is: SERVER[:PORT][,SERVER[:PORT]]... No socket I/O happens here, it is just added to a list. Returns a standard gearman return value.
Get options for a client.
Set options for a client.
Add options for a client.
Remove options for a client.
Get current socket I/O activity timeout value. Returns Timeout in milliseconds to wait for I/O activity.
Set socket I/O activity timeout for connections in milliseconds.
Send data to all job servers to see if they echo it back. This is a test function to see if job servers are responding properly. Returns a standard gearman return value.
Run a single task and return a list with two entries: the first is a standard gearman return value, the second is the result.
Run a high priority task and return a list with two entries: the first is a standard gearman return value, the second is the result.
Run a low priority task and return a list with two entries: the first is a standard gearman return value, the second is the result.
Run a task in the background and return a list with two entries: the first is a standard gearman return value, the second is the job handle.
Run a high priority task in the background and return a list with two entries: the first is a standard gearman return value, the second is the job handle.
Run a low priority task in the background and return a list with two entries: the first is a standard gearman return value, the second is the job handle.
Add a task to be run in parallel and return a list with two entries: the first is a standard gearman return value, the second is a Gearman::XS::Task object.
Add a high priority task to be run in parallel and return a list with two entries: the first is a standard gearman return value, the second is a Gearman::XS::Task object.
Add a low priority task to be run in parallel and return a list with two entries: the first is a standard gearman return value, the second is a Gearman::XS::Task object.
Add a background task to be run in parallel and return a list with two entries: the first is a standard gearman return value, the second is a Gearman::XS::Task object.
Add a high priority background task to be run in parallel and return a list with two entries: the first is a standard gearman return value, the second is a Gearman::XS::Task object.
Add a low priority background task to be run in parallel and return a list with two entries: the first is a standard gearman return value, the second is a Gearman::XS::Task object.
Add task to get the status for a background task in parallel and return a list with two entries: the first is a standard gearman return value, the second is a Gearman::XS::Task object.
Run tasks that have been added in parallel. Returns a standard gearman return value.
Set callback function when a job has been created for a task. No return value.
Set callback function when there is a data packet for a task. No return value.
Set callback function when a task is complete. No return value.
Set callback function when a task has failed. No return value.
Set callback function when there is a status packet for a task. No return value.
Set callback function when there is a warning packet for a task. No return value.
Return an error string for the last error encountered.
Get the status for the running task. Returns a list with the percent complete numerator and denominator.
Get the status for a background job. Returns a list with 5 entries: standard gearman return value, boolean indicating the know status, boolean indicating the running status, and the precent complete numerator and denominator.
When in non-blocking I/O mode, wait for activity from one of the servers.
Clear all task callback functions.
Please make sure that callback functions always explicitly return a valid gearman_return_t value. An implicitly returned value, for example from a print statement can cause the client connection to abort.
Any in libgearman plus many others of my own.
Copyright (C) 2009 Dennis Schoen
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.
This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Dennis Schoen <dennis@blogma.de>
To install Gearman::XS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gearman::XS
CPAN shell
perl -MCPAN -e shell install Gearman::XS
For more information on module installation, please visit the detailed CPAN module installation guide.