AnyEvent-Gearman
view release on metacpan or search on metacpan
---
abstract: 'Asynchronous Gearman client/worker module for AnyEvent applications'
author:
- 'Daisuke Murase <typester@cpan.org>'
build_requires:
ExtUtils::MakeMaker: 6.36
configure_requires:
ExtUtils::MakeMaker: 6.36
distribution_type: module
dynamic_config: 1
generated_by: 'Module::Install version 1.06'
license: perl
inc/Module/Install.pm view on Meta::CPAN
# }
use 5.005;
use strict 'vars';
use Cwd ();
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
$VERSION = '1.06';
# Storage for the pseudo-singleton
$MAIN = undef;
lib/AnyEvent/Gearman.pm view on Meta::CPAN
job_servers => [@_],
);
}
1;
__END__
=head1 NAME
AnyEvent::Gearman - Asynchronous Gearman client/worker module for AnyEvent applications
=head1 SYNOPSIS
use AnyEvent::Gearman;
Client:
my $client = gearman_client '127.0.0.1', '192.168.0.1:123';
$client->add_task(
lib/AnyEvent/Gearman/Worker.pm view on Meta::CPAN
$job->complete($res);
});
C<$function_name> is function name string to register.
C<$subref> is worker CodeRef that will be executed when the worker received a request for this function. And it will be passed a L<AnyEvent::Gearman::Job> object representing the job that has been received by the worker.
NOTE: Unlike L<Gearman::Worker>, this module ignore C<$subref>'s return value.
So you should call either C<< $job->complete >> or C<< $job->fail >> at least.
This is because this module stands L<AnyEvent>'s asynchronous way, and this way more flexible in AnyEvent world.
For example:
$worker->register_function( reverse => sub {
my $job = shift;
my $t; $t = AnyEvent->timer(
after => 10,
cb => sub {
undef $t;
$job->complete('done!');
},
);
});
This is simplest and meaningless codes but you can write worker process with AnyEvent way. This is asynchronous worker.
=head2 unregister_function( $function_name )
Unregister worker function, notifying to server that this worker no longer handle C<$function_name>.
=head1 AUTHOR
Daisuke Murase <typester@cpan.org>
Pedro Melo <melo@cpan.org>
( run in 0.271 second using v1.01-cache-2.11-cpan-0d8aa00de5b )