Test::Gearman - A class for testing and mocking Gearman workers.
version v0.1.0
use Test::Gearman; my $tg = Test::Gearman->new( functions => { reverse => sub { my $job = shift; my $workload = $job->workload(); my $result = reverse($workload); return $result; }, }, ); ## now you can either get a client object from Test::Gearman object my $res = $tg->client->do('reverse', 'this is a test'); ## or build your own use Gearman::XS::Client; my $client = Gearman::XS::Client->new; $client->add_server($tg->host, $tg->port); my $res = $client->do('reverse', 'some other test string');
Test::Gearman is a class for testing Gearman workers.
This class only works with C version of gearmand, and Gearman::XS bindings.
A HashRef of CodeRefs that stores work function names as keys and a CodeRef as work to be done.
Returns a list of all function names.
Returns a CodeRef for the given function name.
Path to Gearman daemon binary. If one is not provided it tries to find it in the $PATH.
$PATH
Note: this must be a C version of gearmand, and not the Perl version as they have different interfaces.
You can also set the path to the binary via $ENV{GEARMAND}.
$ENV{GEARMAND}
Host to which Gearman daemon will bind.
Default is 127.0.0.1.
Port on which gearmand runs. It is picked randomly at the start, but you can manually specify a port if you wish.
Worker timeout in seconds.
Default is 5.
Client timeout in seconds.
An instance of Gearman::XS::Client that you can use to inject jobs.
An instance of Proc::Guard that runs gearmand server.
An instance of Proc::Guard class that runs workers.
Roman F. <romanf@cpan.org>
This software is copyright (c) 2013 by Need Backup.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::Gearman, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Gearman
CPAN shell
perl -MCPAN -e shell install Test::Gearman
For more information on module installation, please visit the detailed CPAN module installation guide.