Minion::Backend::MongoDB - MongoDB backend for Minion
use Minion::Backend::MongoDB; my $backend = Minion::Backend::MongoDB->new('mongodb://127.0.0.1:27017');
Minion::Backend::MongoDB is a MongoDB backend for Minion.
Minion::Backend::MongoDB inherits all attributes from Minion::Backend and implements the following new ones.
my $mongodb = $backend->mongodb; $backend = $backend->mongodb(MongoDB->new);
MongoDB::Database object used to store collections.
my $jobs = $backend->jobs; $backend = $backend->jobs(MongoDB::Collection->new);
MongoDB::Collection object for jobs collection, defaults to one based on "prefix".
jobs
my $notifications = $backend->notifications; $backend = $backend->notifications(MongoDB::Collection->new);
MongoDB::Collection object for notifications collection, defaults to one based on "prefix".
notifications
my $prefix = $backend->prefix; $backend = $backend->prefix('foo');
Prefix for collections, defaults to minion.
minion
my $workers = $backend->workers; $backend = $backend->workers(MongoDB::Collection->new);
MongoDB::Collection object for workers collection, defaults to one based on "prefix".
workers
Minion::Backend::MongoDB inherits all methods from Minion::Backend and implements the following new ones.
my $info = $backend->dequeue($worker_id, 0.5);
Wait for job, dequeue it and transition from inactive to active state or return undef if queue was empty.
inactive
active
undef
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. These options are currently available:
delay => 10
Delay job for this many seconds from now.
priority => 5
Job priority, defaults to 0.
0
my $bool = $backend->fail_job($job_id); my $bool = $backend->fail_job($job_id, 'Something went wrong!');
Transition from active to failed state.
failed
my $bool = $backend->finish_job($job_id);
Transition from active to finished state.
finished
my $info = $backend->job_info($job_id);
Get information about a job or return undef if job does not exist.
my $batch = $backend->list_jobs($skip, $limit); my $batch = $backend->list_jobs($skip, $limit, {state => 'inactive'});
Returns the same information as "job_info" but in batches.
These options are currently available:
state => 'inactive'
List only jobs in this state.
task => 'test'
List only jobs for this task.
my $batch = $backend->list_workers($skip, $limit);
Returns the same information as "worker_info" but in batches.
my $backend = Minion::Backend::MongoDB->new('mongodb://127.0.0.1:27017');
Construct a new Minion::Backend::MongoDB object.
my $worker_id = $backend->register_worker; my $worker_id = $backend->register_worker($worker_id);
Register worker or send heartbeat to show that this worker is still alive.
my $bool = $backend->remove_job($job_id);
Remove failed, finished or inactive job from queue.
$backend->repair;
Repair worker registry and job queue if necessary.
$backend->reset;
Reset job queue.
my $bool = $backend->retry_job($job_id); my $bool = $backend->retry_job($job_id, {delay => 10});
Transition from failed or finished state back to inactive.
Delay job for this many seconds (from now).
my $stats = $backend->stats;
Get statistics for jobs and workers.
$backend->unregister_worker($worker_id);
Unregister worker.
my $info = $backend->worker_info($worker_id);
Get information about a worker or return undef if worker does not exist.
Andrey Khozov <avkhozov@gmail.com>
Copyright (C) 2015, Andrey Khozov.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Minion, MongoDB, http://mojolicio.us.
To install Minion::Backend::MongoDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Minion::Backend::MongoDB
CPAN shell
perl -MCPAN -e shell install Minion::Backend::MongoDB
For more information on module installation, please visit the detailed CPAN module installation guide.