NAME
Minion::Backend::Mango - MongoDB backend
SYNOPSIS
use Minion::Backend::Mango;
my $backend = Minion::Backend::Mango->new('mongodb://127.0.0.1:27017');
DESCRIPTION
Minion::Backend::Mango is a highly scalable Mango backend for Minion.
ATTRIBUTES
Minion::Backend::Mango inherits all attributes from Minion::Backend and implements the following new ones.
jobs
my $jobs = $backend->jobs;
$backend = $backend->jobs(Mango::Collection->new);
Mango::Collection object for jobs
collection, defaults to one based on "prefix".
mango
my $mango = $backend->mango;
$backend = $backend->mango(Mango->new);
Mango object used to store collections.
prefix
my $prefix = $backend->prefix;
$backend = $backend->prefix('foo');
Prefix for collections, defaults to minion
.
workers
my $workers = $backend->workers;
$backend = $backend->workers(Mango::Collection->new);
Mango::Collection object for workers
collection, defaults to one based on "prefix".
METHODS
Minion::Backend::Mango inherits all methods from Minion::Backend 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.
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.
$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.
finish_job
my $bool = $backend->finish_job($job_id);
Transition from active
to finished
state.
job_info
my $info = $backend->job_info($job_id);
Get information about a job or return undef
if job does not exist.
list_jobs
my $batch = $backend->list_jobs($skip, $limit);
Returns the same information as "job_info" but in batches.
list_workers
my $batch = $backend->list_workers($skip, $limit);
Returns the same information as "worker_info" but in batches.
new
my $backend = Minion::Backend::Mango->new('mongodb://127.0.0.1:27017');
Construct a new Minion::Backend::Mango object.
register_worker
my $worker_id = $backend->register_worker;
Register worker.
remove_job
my $bool = $backend->remove_job($job_id);
Remove failed
, finished
or inactive
job from queue.
repair
$backend->repair;
Repair worker registry and job queue.
reset
$backend->reset;
Reset job queue.
restart_job
my $bool = $backend->restart_job($job_id);
Transition from failed
or finished
state back to inactive
.
stats
my $stats = $backend->stats;
Get statistics for jobs and workers.
unregister_worker
$backend->unregister_worker($worker_id);
Unregister worker.
worker_info
my $info = $backend->worker_info($worker_id);
Get information about a worker or return undef
if worker does not exist.