NAME
Jonk::Cookbook::Basic - basic usage for Jonk
USAGE
enqueue script:
#! perl
use strict;
use warnings;
use DBI;
use Jonk
my $dbh = DBI->connect('dbi:mysql:test','user','pass');
my $jonk = Jonk->new($dbh);
my $job_id = $jonk->enqueue('worker_key','job_data_here');
worker script:
#! perl
use strict;
use warnings;
use DBI;
use Jonk;
use Your::Worker;
my $dbh = DBI->connect('dbi:mysql:test','user','pass');
my $jonk = Jonk->new($dbh => {functions => [qw/worker_key/]});
while (1) {
if (my $job = $jonk->find_job) {
Your::Worker->work($job);
} else {
sleep(3); # wait for 3 sec.
}
}