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