line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::AMQP::ConnectionManager; |
2
|
1
|
|
|
1
|
|
1381
|
use Moo; |
|
1
|
|
|
|
|
8290
|
|
|
1
|
|
|
|
|
5
|
|
3
|
1
|
|
|
1
|
|
2228
|
use Types::Standard qw( Bool Str Int ); |
|
1
|
|
|
|
|
103142
|
|
|
1
|
|
|
|
|
16
|
|
4
|
1
|
|
|
1
|
|
1254
|
use Scalar::Util qw/ weaken /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
58
|
|
5
|
1
|
|
|
1
|
|
1460
|
use AnyEvent; |
|
1
|
|
|
|
|
5819
|
|
|
1
|
|
|
|
|
39
|
|
6
|
1
|
|
|
1
|
|
663
|
use AnyEvent::RabbitMQ; |
|
1
|
|
|
|
|
193361
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
9
|
use Carp qw/ croak /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
57
|
|
8
|
1
|
|
|
1
|
|
552
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1692
|
|
|
1
|
|
|
|
|
4
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with qw/ |
11
|
|
|
|
|
|
|
Message::Passing::Role::ConnectionManager |
12
|
|
|
|
|
|
|
Message::Passing::Role::HasHostnameAndPort |
13
|
|
|
|
|
|
|
Message::Passing::Role::HasUsernameAndPassword |
14
|
|
|
|
|
|
|
/; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
|
|
sub _default_port { 5672 } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has vhost => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => Str, |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has tls => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => Bool, |
27
|
|
|
|
|
|
|
default => sub { 0 }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has verbose => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => Bool, |
33
|
|
|
|
|
|
|
default => sub { 0 }, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $has_loaded; |
37
|
|
|
|
|
|
|
sub _build_connection { |
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
weaken($self); |
40
|
|
|
|
|
|
|
my $client = AnyEvent::RabbitMQ->new( |
41
|
|
|
|
|
|
|
verbose => $self->verbose, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
$client->load_xml_spec unless $has_loaded++; |
44
|
|
|
|
|
|
|
$client->connect( |
45
|
|
|
|
|
|
|
host => $self->hostname, |
46
|
|
|
|
|
|
|
port => $self->port, |
47
|
|
|
|
|
|
|
user => $self->username, |
48
|
|
|
|
|
|
|
pass => $self->password, |
49
|
|
|
|
|
|
|
vhost => $self->vhost, |
50
|
|
|
|
|
|
|
tls => $self->tls, |
51
|
|
|
|
|
|
|
timeout => $self->timeout, |
52
|
|
|
|
|
|
|
on_success => sub { |
53
|
|
|
|
|
|
|
$self->_set_connected(1); |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
on_failure => sub { |
56
|
|
|
|
|
|
|
my ($error) = @_; |
57
|
|
|
|
|
|
|
warn("CONNECT ERROR $error"); |
58
|
|
|
|
|
|
|
$self->_set_connected(0); |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
on_close => sub { |
61
|
|
|
|
|
|
|
warn("CLOSED"); |
62
|
|
|
|
|
|
|
$self->_set_connected(0); |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
return $client; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Message::Passing::AMQP::ConnectionManager - Implements the Message::Passing::Role::HasAConnection interface. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 vhost |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Passed to L<AnyEvent::RabbitMQ>->new->connect. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 timeout |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Passed to L<AnyEvent::RabbitMQ>->new->connect. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 tls |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Passed to L<AnyEvent::RabbitMQ>->new->connect. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 verbose |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Passed to L<AnyEvent::RabbitMQ>->new. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
See L<Message::Passing::AMQP>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |