world');
# Meanwhile, in a worker
use Gearman::Worker;
use Garivini::Client;
use JSON;
my $cli = Garivini::Client->new(dbs => {
1 => { id => 1, dsn => 'DBI:mysql:job:host
gister_function('hello' => \&hello);
$worker->work;
sub hello {
my $job = decode_json(${$_[0]->argref});
print "Hello ", $job->{arg}, "\n";
$cli->complete_job($job);
ient
use Gearman::Client;
use JSON;
my $cli = Gearman::Client->new;
$cli->job_servers('127.0.0.1');
$cli->do_task('inject_jobs', \encode_json({ funcname => 'hello',
arg =>
',
);
use Carp qw/croak/;
use Garivini::DB;
use Gearman::Client;
use IO::Socket;
use JSON;
use Data::Dumper qw/Dumper/;
# TODO: Make the "job" table name configurable:
# one dbid creates
iq} = $job->{uniqkey} if $job->{uniqkey};
$client->dispatch_background($funcname, \encode_json($job), \%opts);
}
}
# This isn't your typical worker, as in it doesn't register as a gearman
warnings;
use Garivini::DB;
use Garivini::Client;
use Gearman::Worker;
use Gearman::Client;
use JSON;
use Data::Dumper qw/Dumper/;
use fields (
'job_servers',
'sm_client',
my $self = shift;
my $job = shift;
my $queues = $self->{queues};
my $args = decode_json(${$job->argref});
my $run_job = 1;
if ($queues->{$args->{funcname}} && $queues->{$args->{
eue_watermark_depth}) {
$run_job = 0;
}
# TODO: Uhh if $job->{arg} was a cuddled JSON blob, did this just decode
# that? Easy enough to test and fix, but I'm tired :P
$args->{
);
use Garivini::DB;
use Garivini::Client;
use Gearman::Client;
use Gearman::Worker;
use JSON;
use constant DEBUG => 0;
sub new {
my Garivini::Controller $self = shift;
$self = fiel
$sm_client = $self->{sm_client};
my $gm_client = $self->{gm_client};
my $sm_job = decode_json(${$gm_job->argref});
DEBUG && warn "Got a job $sm_job->{funcname}\n";
# NOTE: This passe
->insert_job(funcname => 'hello', arg => 'world');
# Worker
use Gearman::Worker;
use JSON;
my $cli = Garivini::Client->new(dbs => {
1 => { id => 1, dsn => 'DBI:mysql:job:host
gister_function('hello' => \&hello);
$worker->work;
sub hello {
my $job = decode_json(${$_[0]->argref});
print "Hello ", $job->{arg}, "\n";
$cli->complete_job($job);