line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Minion::Notifier; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
395122
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
785
|
use Minion::Notifier; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
43
|
use Mojo::IOLoop; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
33
|
use Scalar::Util (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
612
|
|
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
|
48
|
my ($plugin, $app, $config) = @_; |
16
|
1
|
|
50
|
|
|
7
|
$config->{minion} ||= eval { $app->minion } || die 'A minion instance is required'; |
|
|
|
33
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
50
|
|
|
138
|
my $transport = $config->{transport} || ''; |
19
|
1
|
50
|
|
|
|
12
|
unless ($transport->$isa('Minion::Notifier::Transport')) { |
20
|
1
|
50
|
|
|
|
29
|
if($transport =~ /^wss?:/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
21
|
1
|
|
|
|
|
863
|
require Minion::Notifier::Transport::WebSocket; |
22
|
1
|
|
|
|
|
12
|
$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
|
|
|
|
|
16
|
my $notifier = Minion::Notifier->new($config); |
35
|
1
|
|
|
1
|
|
17
|
$app->helper(minion_notifier => sub { $notifier }); |
|
1
|
|
|
|
|
137
|
|
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
25
|
$notifier->setup_worker; |
38
|
1
|
|
|
1
|
|
11
|
Mojo::IOLoop->next_tick(sub{ $notifier->setup_listener }); |
|
1
|
|
|
|
|
169
|
|
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
101
|
return $notifier; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|