DOKK / manpages / debian 12 / libminion-perl / Mojolicious::Plugin::Minion.3pm.en
Mojolicious::Plugin::Minion(3pm) User Contributed Perl Documentation Mojolicious::Plugin::Minion(3pm)

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

  # 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;

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

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

  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 jobs for testing
  $app->minion->perform_jobs;

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

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

Register plugin in Mojolicious application.

Minion, Minion::Guide, <https://minion.pm>, Mojolicious::Guides, <https://mojolicious.org>.

2022-10-14 perl v5.34.0