Mojolicious/Plugin/Minion.pm untested

filter: Statementstmt 0.0% 0 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 16 CC 1 SCAR 6.9
CC
1
Cov
0%
register
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Mojolicious::Plugin::Minion;
2 use Mojo::Base 'Mojolicious::Plugin';
3  
4 use Minion;
5  
6 sub register {
7 my ($self, $app, $conf) = @_;
8 push @{$app->commands->namespaces}, 'Minion::Command';
9 my $minion = Minion->new(%$conf)->app($app);
10 $app->helper(minion => sub {$minion});
11 }
12  
13 1;
14  
15 =encoding utf8
16  
17 =head1 NAME
18  
19 Mojolicious::Plugin::Minion - Minion job queue plugin
20  
21 =head1 SYNOPSIS
22  
23 # Mojolicious (choose a backend)
24 $self->plugin(Minion => {Pg => 'postgresql://postgres@/test'});
25  
26 # Mojolicious::Lite (choose a backend)
27 plugin Minion => {Pg => 'postgresql://postgres@/test'};
28  
29 # Share the database connection cache (PostgreSQL backend)
30 helper pg => sub { state $pg = Mojo::Pg->new('postgresql://postgres@/test') };
31 plugin Minion => {Pg => app->pg};
32  
33 # Add tasks to your application
34 app->minion->add_task(slow_log => sub ($job, $msg) {
35 sleep 5;
36 $job->app->log->debug(qq{Received message "$msg"});
37 });
38  
39 # Start jobs from anywhere in your application
40 $c->minion->enqueue(slow_log => ['test 123']);
41  
42 # Perform jobs in your tests
43 $t->get_ok('/start_slow_log_job')->status_is(200);
44 $t->get_ok('/start_another_job')->status_is(200);
45 $t->app->minion->perform_jobs;
46  
47 =head1 DESCRIPTION
48  
49 L<Mojolicious::Plugin::Minion> is a L<Mojolicious> plugin for the L<Minion> job queue.
50  
51 =head1 HELPERS
52  
53 L<Mojolicious::Plugin::Minion> implements the following helpers.
54  
55 =head2 minion
56  
57 my $minion = $app->minion;
58 my $minion = $c->minion;
59  
60 Get L<Minion> object for application.
61  
62 # Add job to the queue
63 $c->minion->enqueue(foo => ['bar', 'baz']);
64  
65 # Perform jobs for testing
66 $app->minion->perform_jobs;
67  
68 =head1 METHODS
69  
70 L<Mojolicious::Plugin::Minion> inherits all methods from L<Mojolicious::Plugin> and implements the following new ones.
71  
72 =head2 register
73  
74 $plugin->register(Mojolicious->new, {Pg => 'postgresql://postgres@/test'});
75  
76 Register plugin in L<Mojolicious> application.
77  
78 =head1 SEE ALSO
79  
80 L<Minion>, L<Minion::Guide>, L<https://minion.pm>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
81  
82 =cut