1Mojolicious::Plugin::MiUnsieorn(C3o)ntributed Perl DocumMeonjtoaltiicoinous::Plugin::Minion(3)
2
3
4
6 Mojolicious::Plugin::Minion - Minion job queue plugin
7
9 # Mojolicious (choose a backend)
10 $self->plugin(Minion => {Pg => 'postgresql://postgres@/test'});
11
12 # Mojolicious::Lite (choose a backend)
13 plugin Minion => {Pg => 'postgresql://postgres@/test'};
14
15 # Share the database connection cache (PostgreSQL backend)
16 helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test') };
17 plugin Minion => {Pg => app->pg};
18
19 # Add tasks to your application
20 app->minion->add_task(slow_log => sub {
21 my ($job, $msg) = @_;
22 sleep 5;
23 $job->app->log->debug(qq{Received message "$msg"});
24 });
25
26 # Start jobs from anywhere in your application
27 $c->minion->enqueue(slow_log => ['test 123']);
28
29 # Perform jobs in your tests
30 $t->get_ok('/start_slow_log_job')->status_is(200);
31 $t->get_ok('/start_another_job')->status_is(200);
32 $t->app->minion->perform_jobs;
33
35 Mojolicious::Plugin::Minion is a Mojolicious plugin for the Minion job
36 queue.
37
39 Mojolicious::Plugin::Minion implements the following helpers.
40
41 minion
42 my $minion = $app->minion;
43 my $minion = $c->minion;
44
45 Get Minion object for application.
46
47 # Add job to the queue
48 $c->minion->enqueue(foo => ['bar', 'baz']);
49
50 # Perform jobs for testing
51 $app->minion->perform_jobs;
52
54 Mojolicious::Plugin::Minion inherits all methods from
55 Mojolicious::Plugin and implements the following new ones.
56
57 register
58 $plugin->register(Mojolicious->new, {Pg => 'postgresql://postgres@/test'});
59
60 Register plugin in Mojolicious application.
61
63 Minion, Mojolicious::Guides, <https://mojolicious.org>.
64
65
66
67perl v5.30.0 2019-09-01 Mojolicious::Plugin::Minion(3)