line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
23392
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
229
|
|
2
|
6
|
|
|
6
|
|
23
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
291
|
|
3
|
|
|
|
|
|
|
package Juno::Role::Check; |
4
|
|
|
|
|
|
|
# ABSTRACT: Check role for Juno |
5
|
|
|
|
|
|
|
$Juno::Role::Check::VERSION = '0.010'; |
6
|
6
|
|
|
6
|
|
1254
|
use AnyEvent; |
|
6
|
|
|
|
|
4306
|
|
|
6
|
|
|
|
|
110
|
|
7
|
6
|
|
|
6
|
|
21
|
use Moo::Role; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
39
|
|
8
|
6
|
|
|
6
|
|
1698
|
use MooX::Types::MooseLike::Base qw; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
405
|
|
9
|
6
|
|
|
6
|
|
2844
|
use PerlX::Maybe; |
|
6
|
|
|
|
|
9336
|
|
|
6
|
|
|
|
|
288
|
|
10
|
6
|
|
|
6
|
|
459
|
use namespace::sweep; |
|
6
|
|
|
|
|
11284
|
|
|
6
|
|
|
|
|
50
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'MooseX::Role::Loggable'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has hosts => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
17
|
|
|
|
|
|
|
default => sub { [] }, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has interval => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => Num, |
23
|
|
|
|
|
|
|
default => sub {10}, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has after => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => Num, |
29
|
|
|
|
|
|
|
default => sub {0}, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has on_before => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
isa => CodeRef, |
35
|
|
|
|
|
|
|
predicate => 1, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has on_result => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
isa => CodeRef, |
41
|
|
|
|
|
|
|
predicate => 1, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has on_success => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => CodeRef, |
47
|
|
|
|
|
|
|
predicate => 1, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has on_fail => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
isa => CodeRef, |
53
|
|
|
|
|
|
|
predicate => 1, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has watcher => ( |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
writer => 'set_watcher', |
59
|
|
|
|
|
|
|
clearer => 1, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
requires 'check'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub run { |
65
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# keep a watcher per check |
68
|
|
|
|
|
|
|
$self->set_watcher( AnyEvent->timer( |
69
|
|
|
|
|
|
|
maybe after => $self->after, |
70
|
|
|
|
|
|
|
interval => $self->interval, |
71
|
3
|
|
|
3
|
|
89180
|
cb => sub { $self->check }, |
72
|
2
|
|
|
|
|
37
|
) ); |
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
1921
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |