NAME
Minion::Backend - Backend base class
SYNOPSIS
package Minion::Backend::MyBackend;
use Mojo::Base 'Minion::Backend';
sub dequeue {...}
sub enqueue {...}
sub fail_job {...}
sub finish_job {...}
sub job_info {...}
sub list_jobs {...}
sub list_workers {...}
sub register_worker {...}
sub remove_job {...}
sub repair {...}
sub reset {...}
sub restart_job {...}
sub stats {...}
sub unregister_worker {...}
sub worker_info {...}
DESCRIPTION
Minion::Backend is an abstract base class for Minion backends.
ATTRIBUTES
Minion::Backend implements the following attributes.
minion
my $minion = $backend->minion;
$backend = $backend->minion(Minion->new);
Minion object this backend belongs to.
METHODS
Minion::Backend inherits all methods from Mojo::Base and implements the following new ones.
dequeue
my $info = $backend->dequeue($worker_id);
Dequeue job and transition from inactive
to active
state or return undef
if queue was empty. Meant to be overloaded in a subclass.
enqueue
my $job_id = $backend->enqueue('foo');
my $job_id = $backend->enqueue(foo => [@args]);
my $job_id = $backend->enqueue(foo => [@args] => {priority => 1});
Enqueue a new job with inactive
state. You can also append a callback to perform operation non-blocking. Meant to be overloaded in a subclass.
$backend->enqueue(foo => sub {
my ($backend, $err, $job_id) = @_;
...
});
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
fail_job
my $bool = $backend->fail_job($job_id);
my $bool = $backend->fail_job($job_id, 'Something went wrong!');
Transition from active
to failed
state. Meant to be overloaded in a subclass.
finish_job
my $bool = $backend->finish_job($job_id);
Transition from active
to finished
state. Meant to be overloaded in a subclass.
job_info
my $info = $backend->job_info($job_id);
Get information about a job or return undef
if job does not exist. Meant to be overloaded in a subclass.
list_jobs
my $batch = $backend->list_jobs($skip, $limit);
Returns the same information as "job_info" but in batches. Meant to be overloaded in a subclass.
list_workers
my $batch = $backend->list_workers($skip, $limit);
Returns the same information as "worker_info" but in batches. Meant to be overloaded in a subclass.
register_worker
my $worker_id = $backend->register_worker;
Register worker. Meant to be overloaded in a subclass.
remove_job
my $bool = $backend->remove_job($job_id);
Remove failed
, finished
or inactive
job from queue. Meant to be overloaded in a subclass.
repair
$backend->repair;
Repair worker registry and job queue. Meant to be overloaded in a subclass.
reset
$backend->reset;
Reset job queue. Meant to be overloaded in a subclass.
restart_job
my $bool = $backend->restart_job($job_id);
Transition from failed
or finished
state back to inactive
. Meant to be overloaded in a subclass.
stats
my $stats = $backend->stats;
Get statistics for jobs and workers. Meant to be overloaded in a subclass.
unregister_worker
$backend->unregister_worker($worker_id);
Unregister worker. Meant to be overloaded in a subclass.
worker_info
my $info = $backend->worker_info($worker_id);
Get information about a worker or return undef
if worker does not exist. Meant to be overloaded in a subclass.