line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::amqp; |
2
|
3
|
|
|
3
|
|
1771
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
66
|
|
3
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
89
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.1.2'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1163
|
use URI::QueryParam; |
|
3
|
|
|
|
|
1722
|
|
|
3
|
|
|
|
|
78
|
|
8
|
3
|
|
|
3
|
|
16
|
use URI::Escape qw(uri_unescape); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
148
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
403
|
use parent qw(URI::_server URI::_userpass); |
|
3
|
|
|
|
|
220
|
|
|
3
|
|
|
|
|
16
|
|
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
1
|
29195
|
sub default_port { 5672 } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
URI::amqp - AMQP (RabbitMQ) URI |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $uri = URI->new('amqp://user:pass@host.domain:1234/'); |
21
|
|
|
|
|
|
|
my $ar = AnyEvent::RabbitMQ->new->load_xml_spec()->connect( |
22
|
|
|
|
|
|
|
host => $uri->host, |
23
|
|
|
|
|
|
|
port => $uri->port, |
24
|
|
|
|
|
|
|
user => $uri->user, |
25
|
|
|
|
|
|
|
pass => $uri->password, |
26
|
|
|
|
|
|
|
vhost => $uri->vhost, |
27
|
|
|
|
|
|
|
tls => $uri->secure, |
28
|
|
|
|
|
|
|
heartbeat => scalar $uri->query_param('heartbeat'), |
29
|
|
|
|
|
|
|
... |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
URI extension for AMQP protocol (L) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 EXTENDED METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 vhost |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
vhost is path part of URI |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
slash C> on start is removed (this is different with C method) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return C if vhost not defined (should be used default of module which use this URI module) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub vhost { |
49
|
15
|
|
|
15
|
1
|
18194
|
my ($self) = @_; |
50
|
|
|
|
|
|
|
|
51
|
15
|
|
|
|
|
49
|
my $vhost = $self->path; |
52
|
15
|
|
|
|
|
219
|
$vhost =~ s/^\///; |
53
|
|
|
|
|
|
|
|
54
|
15
|
100
|
|
|
|
64
|
return if !length $vhost; |
55
|
|
|
|
|
|
|
|
56
|
7
|
|
|
|
|
22
|
return uri_unescape($vhost); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 query_param |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return query parameters (L) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
implement by L module |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 as_net_amqp_rabbitmq |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return tuplet of C<($host, $options)> which works with L C method |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use URI; |
70
|
|
|
|
|
|
|
use Net::AMQP::RabbitMQ; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $uri = URI->new('amqp://guest:guest@localhost'); |
73
|
|
|
|
|
|
|
my $mq = Net::AMQP::RabbitMQ->new(); |
74
|
|
|
|
|
|
|
$mq->connect($uri->as_net_amqp_rabbitmq_options); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub as_net_amqp_rabbitmq { |
79
|
1
|
|
|
1
|
1
|
171
|
my ($self) = @_; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return ( |
82
|
1
|
|
|
|
|
4
|
$self->host, |
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
user => $self->user, |
85
|
|
|
|
|
|
|
password => $self->password, |
86
|
|
|
|
|
|
|
port => $self->port, |
87
|
|
|
|
|
|
|
vhost => $self->vhost, |
88
|
|
|
|
|
|
|
channel_max => scalar $self->query_param('channel_max'), |
89
|
|
|
|
|
|
|
frame_max => scalar $self->query_param('frame_max'), |
90
|
|
|
|
|
|
|
heartbeat => scalar $self->query_param('heartbeat'), |
91
|
|
|
|
|
|
|
timeout => scalar $self->query_param('connection_timeout'), |
92
|
|
|
|
|
|
|
ssl => $self->secure, |
93
|
|
|
|
|
|
|
ssl_verify_host => scalar $self->query_param('verify'), |
94
|
|
|
|
|
|
|
ssl_cacert => scalar $self->query_param('cacertfile'), |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 as_anyevent_rabbitmq |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
return options which works with L C method |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use URI; |
104
|
|
|
|
|
|
|
use AnyEvent::RabbitMQ; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $cv = AnyEvent->condvar; |
107
|
|
|
|
|
|
|
my $uri = URI->new('amqp://user:pass@host.domain:1234/'); |
108
|
|
|
|
|
|
|
my $ar = AnyEvent::RabbitMQ->new->load_xml_spec()->connect( |
109
|
|
|
|
|
|
|
$uri->as_anyevent_rabbitmq(), |
110
|
|
|
|
|
|
|
on_success => sub { |
111
|
|
|
|
|
|
|
... |
112
|
|
|
|
|
|
|
}, |
113
|
|
|
|
|
|
|
... |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub as_anyevent_rabbitmq { |
119
|
1
|
|
|
1
|
1
|
171
|
my ($self) = @_; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
return { |
122
|
1
|
|
|
|
|
5
|
host => $self->host, |
123
|
|
|
|
|
|
|
port => $self->port, |
124
|
|
|
|
|
|
|
user => $self->user, |
125
|
|
|
|
|
|
|
pass => $self->password, |
126
|
|
|
|
|
|
|
vhost => $self->vhost, |
127
|
|
|
|
|
|
|
timeout => scalar $self->query_param('connection_timeout'), |
128
|
|
|
|
|
|
|
tls => $self->secure, |
129
|
|
|
|
|
|
|
tune => { |
130
|
|
|
|
|
|
|
heartbeat => scalar $self->query_param('heartbeat'), |
131
|
|
|
|
|
|
|
channel_max => scalar $self->query_param('channel_max'), |
132
|
|
|
|
|
|
|
frame_max => scalar $self->query_param('frame_max'), |
133
|
|
|
|
|
|
|
}, |
134
|
|
|
|
|
|
|
}; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 LIMITATIONS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
module doesn't support correct C (reverse) method (yet) |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 LICENSE |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Copyright (C) Avast Software. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
146
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Jan Seidl Eseidl@avast.comE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |