line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::App::ServiceStatus::NetStomp; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Check Net::Stomp connection |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.909'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
79194
|
use 5.018; |
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
10
|
1
|
|
|
1
|
|
559
|
use Module::Runtime qw(require_module); |
|
1
|
|
|
|
|
1830
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
553
|
use Try::Tiny; |
|
1
|
|
|
|
|
2160
|
|
|
1
|
|
|
|
|
253
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub check { |
14
|
4
|
|
|
4
|
0
|
8564
|
my ( $class, $stomp ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
4
|
100
|
|
|
|
16
|
if ( ref $stomp eq 'CODE' ) { |
17
|
2
|
|
|
|
|
5
|
$stomp = $stomp->(); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
18
|
require_module 'Net::Stomp::Frame'; |
21
|
4
|
|
|
|
|
173
|
my $reconnect_attempts = $stomp->reconnect_attempts(); |
22
|
|
|
|
|
|
|
return try { |
23
|
4
|
|
|
4
|
|
297
|
$stomp->reconnect_attempts(1); |
24
|
4
|
|
|
|
|
268
|
my $transaction_id = $stomp->_get_next_transaction; |
25
|
4
|
|
|
|
|
238
|
my $begin_frame = Net::Stomp::Frame->new( |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
command => 'BEGIN', |
28
|
|
|
|
|
|
|
headers => { transaction => $transaction_id } |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
); |
31
|
4
|
|
|
|
|
32
|
$stomp->send_frame($begin_frame); |
32
|
2
|
|
|
|
|
118
|
my $abort_frame = Net::Stomp::Frame->new( |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
command => 'ABORT', |
35
|
|
|
|
|
|
|
headers => { transaction => $transaction_id } |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
); |
38
|
2
|
|
|
|
|
15
|
$stomp->send_frame($abort_frame); |
39
|
2
|
|
|
|
|
114
|
return 'ok'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
catch { |
42
|
2
|
|
|
2
|
|
158
|
return 'nok', 'Not connected: ' . $_; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
finally { |
45
|
4
|
|
|
4
|
|
69
|
$stomp->reconnect_attempts($reconnect_attempts); |
46
|
|
|
|
|
|
|
} |
47
|
4
|
|
|
|
|
314
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |