Gearman::Glutch - gearman casual
use Gearman::Glutch; my $worker = Gearman::Glutch->new( port => 9999, max_workers => 5, max_reqs_per_child => 5, on_spawn_child => sub { warn "Spawned $_[0]"; }, on_complete => sub { warn "Complete job $$"; }, ); $worker->register_function("echo", sub { my $job = shift; $$.":".$job->arg; }); $worker->run();
Gearman::Glutch is all in one gearman server management library for casual use. Glutch spawns Gearman::Server and Gearman::Worker automatically.
Create new instance of Gearman::Glutch. You can pass the following arguments.
Port number for gearman server.
number of worker processes
max. number of requests to be handled before a worker process exits
Callback function. This will call on spawned worker process.
Callback function. This will call on completed one job.
$glutch->register_function("echo", sub { my $job = shift; # $job is instance of Gearman::Job $$.":".$job->arg; });
Register function to the worker processes.
Spawn the child processes and go to main loop.
Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>
Copyright (C) Tokuhiro Matsuno
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Gearman::Glutch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gearman::Glutch
CPAN shell
perl -MCPAN -e shell install Gearman::Glutch
For more information on module installation, please visit the detailed CPAN module installation guide.