NAME

Mojolicious::Plugin::Minion - Minion job queue plugin

SYNOPSIS

# Mojolicious
$self->plugin(Minion => {uri => 'mongodb://127.0.0.1:27017'});

# Mojolicious::Lite
plugin Minion => {uri => 'mongodb://127.0.0.1:27017'};

# Add tasks to your application
app->minion->add_task(slow_log => sub {
  my ($job, $msg) = @_;
  sleep 5;
  $job->app->log->debug(qq{Received message "$msg".});
});

# Start jobs from anywhere in your application (data gets BSON serialized)
$c->minion->enqueue(slow_log => ['test 123']);

# Perform jobs in your tests
$t->get_ok('/start_job')->status_is(200);
my $worker = $t->app->minion->worker;
$worker->all_jobs;

DESCRIPTION

Mojolicious::Plugin::Minion is a Mojolicious plugin for the Minion job queue.

OPTIONS

Mojolicious::Plugin::Minion supports the following options.

uri

# Mojolicious::Lite
plugin Minion => {uri => 'mongodb://127.0.0.1:27017'};

Mango connection string.

HELPERS

Mojolicious::Plugin::Minion implements the following helpers.

minion

my $minion = $app->minion;
my $minion = $c->minion;

Get Minion object for application.

# Add job to the queue
$c->minion->enqueue(foo => ['bar', 'baz']);

# Perform queued jobs right away for testing
my $worker = $app->minion->worker;
$worker->all_jobs;

METHODS

Mojolicious::Plugin::Minion inherits all methods from Mojolicious::Plugin and implements the following new ones.

register

$plugin->register(Mojolicious->new, {uri => 'mongodb://127.0.0.1:27017'});

Register plugin in Mojolicious application.

SEE ALSO

Minion, Mojolicious::Guides, http://mojolicio.us.