NAME
Jonk - simple job tank manager.
SYNOPSIS
use DBI;
use Jonk;
my $dbh = DBI->connect(...);
my $jonk = Jonk->new($dbh, {functions => [qw/MyWorker/]});
# insert job
{
$jonk->insert('MyWorker', 'arg');
}
# execute job
{
my $job = $jonk->find_job;
print $job->func; # MyWorker
print $job->arg; # arg
$job->completed;
}
DESCRIPTION
Jonk is simple job queue manager system
Job is saved and taken out. Besides, nothing is done.
You may use Jonk to make original Job Queuing System.
METHODS
my $jonk = Jonk::Worker->new($dbh, [\%options]);
Creates a new Jonk object, and returns the object.
$options is an optional settings.
$dbh
$dbh is database handle.
$options->{functions}
Key word of job which this Jonk instance looks for.
$options->{table_name}
specific job table name.
Default job table name is `job`.
$options->{job_find_size}
specific lookup job record size.
Default 50.
my $job_id = $jonk->insert($func, $arg);
enqueue a job to a database. returns job.id.
$func
specific your worker funcname.
$arg
job argument data.
serialize is not done in Jonk.
Please pass data that does serialize if it is necessary.
my $job = $jonk->lookup_job($job_id);
lookup a job from a database.
returns Jonk::Job object.
$job_id
lookup specific $job_id's job.
my $job = $jonk->find_job(\%opts);
$opts->{job_find_size}
find job limit size.
$jonk->errstr;
get most recent error infomation.
ERROR HANDLING
my $job = $jonk->lookup;
if ($jonk->errstr) {
die $jonk->errstr;
}
SCHEMA
MySQL
CREATE TABLE job (
id int(10) UNSIGNED NOT NULL auto_increment,
func varchar(255) NOT NULL,
arg MEDIUMBLOB,
enqueue_time DATETIME NOT NULL,
grabbed_until int(10) UNSIGNED NOT NULL,
run_after int(10) UNSIGNED NOT NULL DEFAULT 0,
retry_cnt int(10) UNSIGNED NOT NULL DEFAULT 0,
priority int(10) UNSIGNED NOT NULL DEFAULT 0,
primary key ( id )
) ENGINE=InnoDB
SQLite
CREATE TABLE job (
id INTEGER PRIMARY KEY ,
func text,
arg text,
enqueue_time text,
grabbed_until INTEGER UNSIGNED NOT NULL,
run_after INTEGER UNSIGNED NOT NULL DEFAULT 0,
retry_cnt INTEGER UNSIGNED NOT NULL DEFAULT 0,
priority INTEGER UNSIGNED NOT NULL DEFAULT 0
)
PostgreSQL
CREATE TABLE job (
id SERIAL PRIMARY KEY,
func TEXT NOT NULL,
arg BYTEA,
enqueue_time TIMESTAMP NOT NULL,
grabbed_until INTEGER NOT NULL,
run_after INTEGER NOT NULL DEFAULT 0,
retry_cnt INTEGER NOT NULL DEFAULT 0,
priority INTEGER NOT NULL DEFAULT 0
)
SEE ALSO
SUPPORT
irc: #jonk@irc.perl.org
REPOSITORY
git clone git://github.com/nekokak/p5-Jonk.git
CONTRIBUTORS
tokuhirom
kan_fushihara
fujiwara
AUTHOR
Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.