NAME

Jonk::Client - job enqueue client class.

SYNOPSIS

use DBI; 
use Jonk::Client;
use DateTime;

my $dbh = DBI->connect(...);
my $jonk = Jonk::Client->new($dbh, 
    {
        table_name => 'jonk_job',
        enqueue_time_callback => sub {
            DateTime->now->strftime('%Y-%m-%d %H:%M:%S');
        },
    }
);

METHODS

my $jonk = Jonk::Client->new($dbh, $options);

Creates a new Jonk object, and returns the object.

$option is an optional settings.

  • $dbh

    $dbh is database handle.

  • $options->{table_name}

    specific job table name.

    Default job table name is `job`.

  • $options->{enqueue_time_callback}

    specific enqueue_time creation callback.

    Default local time create.

my $job_id = $jonk->enqueue($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 $errstr = $jonk->errstr;

get most recent error infomation.

ERROR HANDLING

my $job_id = $jonk->enqueue('func','arg');
if ($jonk->errstr) {
    die $jonk->errstr;
}