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