line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Minion::Notifier; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
97561
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
521
|
use Minion::Notifier; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
31
|
use Mojo::IOLoop; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
21
|
use Scalar::Util (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
382
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $isa = sub { |
10
|
|
|
|
|
|
|
my ($obj, $class) = @_; |
11
|
|
|
|
|
|
|
return $obj && Scalar::Util::blessed($obj) && $obj->isa($class); |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub register { |
15
|
1
|
|
|
1
|
1
|
34
|
my ($plugin, $app, $config) = @_; |
16
|
1
|
|
50
|
|
|
6
|
$config->{minion} ||= eval { $app->minion } || die 'A minion instance is required'; |
|
|
|
33
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
50
|
|
|
128
|
my $transport = $config->{transport} || ''; |
19
|
1
|
50
|
|
|
|
8
|
unless ($transport->$isa('Minion::Notifier::Transport')) { |
20
|
1
|
50
|
|
|
|
19
|
if($transport =~ /^wss?:/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
21
|
1
|
|
|
|
|
879
|
require Minion::Notifier::Transport::WebSocket; |
22
|
1
|
|
|
|
|
8
|
$config->{transport} = Minion::Notifier::Transport::WebSocket->new(url => $transport); |
23
|
|
|
|
|
|
|
} elsif ($transport =~ /^redis:/) { |
24
|
0
|
|
|
|
|
0
|
require Mojo::Redis2; |
25
|
0
|
|
|
|
|
0
|
require Minion::Notifier::Transport::Redis; |
26
|
0
|
|
|
|
|
0
|
my $redis = Mojo::Redis2->new(url => $transport); |
27
|
0
|
|
|
|
|
0
|
$config->{transport} = Minion::Notifier::Transport::Redis->new(redis => $redis); |
28
|
|
|
|
|
|
|
} elsif ($config->{minion}->backend->isa('Minion::Backend::Pg')) { |
29
|
0
|
|
|
|
|
0
|
require Minion::Notifier::Transport::Pg; |
30
|
0
|
|
|
|
|
0
|
$config->{transport} = Minion::Notifier::Transport::Pg->new(pg => $config->{minion}->backend->pg); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
11
|
my $notifier = Minion::Notifier->new($config); |
35
|
1
|
|
|
1
|
|
14
|
$app->helper(minion_notifier => sub { $notifier }); |
|
1
|
|
|
|
|
101
|
|
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
99
|
$notifier->setup_worker; |
38
|
1
|
|
|
1
|
|
8
|
Mojo::IOLoop->next_tick(sub{ $notifier->setup_listener }); |
|
1
|
|
|
|
|
145
|
|
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
91
|
return $notifier; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|