Mojolic...::Minion(3)

πŸ’– Mojolic...::Minion(3) πŸ’–

okay bestie, this is a page from the User Contributed Perl Documentation set, and it's all about the plugin that plugs a whole job queue into your Mojolicious app. no cap. let's get into it.


✨ NAME ✨

Mojolicious::Plugin::Minion β€” the Minion job queue plugin, fr fr πŸ‘‘


🌸 SYNOPSIS 🌸

like, here's the whole vibe in code form:

# Mojolicious (choose a backend)
$self->plugin(Minion => {Pg => 'postgresql://postgres@/test'});

# Mojolicious::Lite (choose a backend)
plugin Minion => {Pg => 'postgresql://postgres@/test'};

# Share the database connection cache (PostgreSQL backend)
helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test') };
plugin Minion => {Pg => app->pg};

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

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

# Perform jobs in your tests
$t->get_ok('/start_slow_log_job')->status_is(200);
$t->get_ok('/start_another_job')->status_is(200);
$t->app->minion->perform_jobs;

notice how we choose a backend both times? that's the move. and yes, you can share the database connection cache with the PostgreSQL backend. iconic. πŸ¦‹


πŸ’… DESCRIPTION πŸ’…

Mojolicious::Plugin::Minion is a Mojolicious plugin for the Minion job queue. that's it, that's the whole description, and honestly? it understood the assignment. πŸŽ€


⭐ HELPERS ⭐

Mojolicious::Plugin::Minion implements the following helpers. not a lot, but she's serving.

🫢 minion

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

Get the Minion object for your application. literally grab it from either spot, no drama.

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

# Perform jobs for testing
$app->minion->perform_jobs;

enqueue when you're out here living your life, perform_jobs when you're testing. both valid. both slay. πŸ”₯


πŸ‘‘ METHODS πŸ‘‘

Mojolicious::Plugin::Minion inherits all methods from Mojolicious::Plugin and implements the following new ones. inherited plus extra, the way that growth works. 🌈

πŸ’œ register

$plugin->register(Mojolicious->new, {Pg => 'postgresql://postgres@/test'});

Register the plugin in a Mojolicious application. one line, whole job queue unlocked. main character energy. ✨


🌟 SEE ALSO 🌟

go read those too, iykyk πŸ“š


no warnings, no bugs, no deprecated anything on this page β€” just pure clean plugin energy. we love to see it πŸ’–

and that's the whole page, bestie!! this one came to you courtesy of perl v5.42.0, dated 2026-01-17 β€” so if you're reading this on a date that is not that date, hi from the future/past, the vibe still holds. periodt. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from