Lim/RPC/Transport/RabbitMQ.pm

filter: Statementstmt 10.7% 41 / 381 Branchbran 0.0% 0 / 226 Conditioncond 0.0% 0 / 132 MC/DCmcdc 0.0% 0 / 67 Subroutinesub 21.3% 13 / 61 Podpod 100% 8 / 8 totaltotal 7.0% 62 / 875 CC 163 SCAR 43.9
CC
163
Cov
6%
__ANON__
462.0
Init
132.0
__ANON__
90.0
CRAP 80.4
« Lim/RPC/Transport/Clients.pm ↑ Summary Lim/RPC.pm »
1 package Lim::RPC::Transport::RabbitMQ;
2  
3 5 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Scalar::Util qw(blessed weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use AnyEvent ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶eval 'use AnyEvent::RabbitMQ ();';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 undef $@;
11  
12 5 ▶use HTTP::Status qw(:constants);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use HTTP::Request ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use HTTP::Response ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 5 ▶use Lim ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use Lim::RPC::Callback ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use Lim::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 5 ▶use base qw(Lim::RPC::Transport);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 =encoding utf8
23  
24 =head1 NAME
25  
26 ...
27  
28 =head1 VERSION
29  
30 See L<Lim> for version.
31  
32 =cut
33  
34 5 our $VERSION = $Lim::VERSION;
35  
36 =head1 SYNOPSIS
37  
38 ...
39  
40 =head1 SUBROUTINES/METHODS
41  
42 =head2 Init
43  
44 =cut
45  
46 0 ▶sub Init {
Subroutine Init: not called CC=11 SCAR=48.8
Pod documented
47 0 my $self = shift;
48 0 my %args = ( @_ );
49 0 my $real_self = $self;
50 0 weaken($self);
51  
52 0 $self->{channel} = {};
53 0 $self->{host} = 'localhost';
54 0 $self->{port} = 5672;
55 0 $self->{user} = 'guest';
56 0 $self->{pass} = 'guest';
57 0 $self->{vhost} = '/';
58 0 $self->{timeout} = 10;
59 0 $self->{queue_prefix} = 'lim_';
60 0 $self->{verbose} = 0;
61 0 $self->{prefetch_count} = 1;
62 0 $self->{broadcast} = 0;
63 0 $self->{exchange_prefix} = 'lim_exchange_';
64 0 $self->{retry_interval} = 5;
65 0 $self->{closing} = 0;
66  
67 0 foreach (qw(host port user pass vhost timeout queue_prefix verbose prefetch_count broadcast exchange_prefix retry_interval)) {
68 0 ▶ if (defined Lim::Config->{rpc}->{transport}->{rabbitmq}->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined &Lim::Config()->{"rpc"}{"transport"}{"rabbitmq"}{$_}) 0 0 0
69 0 $self->{$_} = Lim::Config->{rpc}->{transport}->{rabbitmq}->{$_};
70 }
71 }
72 0 foreach (qw(host port user pass vhost timeout queue_prefix verbose prefetch_count broadcast exchange_prefix retry_interval)) {
73 0 ▶ if (defined $args{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{$_}) 0 0 0
74 0 $self->{$_} = $args{$_};
75 }
76 }
77  
78 0 ▶ if (exists $args{uri}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"uri"}) 0 0 0
79 0 ▶ unless (blessed($args{uri}) and $args{uri}->isa('URI')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($args{"uri"}) and $args{"uri"}->isa("URI")) 0 0 0
Condition0%0/3
builtin::blessed($args{"uri"}) and $args{"uri"}->isa("URI")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($args{"uri"}) and $args{"uri"}->isa("URI")
builtin::blessed($args{"uri"}) $args{"uri"}->isa("URI")
Truth table0%0/3
A and B
A= builtin::blessed($args{"uri"})B= $args{"uri"}->isa("URI")
ABresult
0X0
100
111
80 0 confess 'uri argument is not a URI class';
81 }
82  
83 0 $self->{host} = $args{uri}->host;
84 0 $self->{port} = $args{uri}->port;
85 }
86  
87 0 eval {
88 0 $self->{rabbitmq} = AnyEvent::RabbitMQ->new(verbose => $self->{verbose})->load_xml_spec;
89 };
90 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
91 0 confess 'Failed to initiate AnyEvent::RabbitMQ: '.$@;
92 }
93 0 ▶ unless (blessed $self->{rabbitmq} and $self->{rabbitmq}->isa('AnyEvent::RabbitMQ')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($self->{"rabbitmq"}) and $self->{"rabbitmq"}->isa("AnyEvent::RabbitMQ")) 0 0 0
Condition0%0/3
builtin::blessed($self->{"rabbitmq"}) and $self->{"rabbitmq"}->isa("AnyEvent::RabbitMQ")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($self->{"rabbitmq"}) and $self->{"rabbitmq"}->isa("AnyEvent::RabbitMQ")
builtin::blessed($self->{"rabbitmq"}) $self->{"rabbitmq"}->isa("AnyEvent::RabbitMQ")
Truth table0%0/3
A and B
A= builtin::blessed($self->{"rabbitmq"})B= $self->{"rabbitmq"}->isa("AnyEvent::RabbitMQ")
ABresult
0X0
100
111
94 0 confess 'unable to create AnyEvent::RabbitMQ object';
95 }
96  
97 0 $self->_resolve;
98 }
99  
100 =head2 _resolve
101  
102 =cut
103  
104 0 ▶sub _resolve {
Subroutine _resolve: not called CC=2 SCAR=17.9
105 0 my ($self) = @_;
106 0 my $real_self = $self;
107 0 weaken($self);
108  
109 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Resolving ', $self->{host}, '...');
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("Resolving ", $self->{"host"}, "...") 0 0 0
110  
111 0 ▶ Lim::Util::resolve_host $self->{host}, $self->{port}, sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
112 0 my ($host, $port) = @_;
113  
114 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
115 0 return;
116 }
117  
118 0 ▶ unless (defined $host and defined $port) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $host and defined $port) 0 0 0
Condition0%0/3
defined $host and defined $port
!ll&&!rl&&r
000
MC/DC0%0/2
defined $host and defined $port
defined $host defined $port
Truth table0%0/3
A and B
A= defined $hostB= defined $port
ABresult
0X0
100
111
119 0 ▶ Lim::WARN and $self->{logger}->warn('Unable to resolve host ', $self->{host});
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->warn("Unable to resolve host ", $self->{"host"}) 0 0 0
120 0 ▶ $self->{retry} = AnyEvent->timer(after => $self->{retry_interval}, cb => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
121 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
122 0 return;
123 }
124  
125 0 $self->_resolve;
126 0 });
127 0 return;
128 }
129  
130 0 $self->{host} = $host;
131 0 $self->{port} = $port;
132 0 $self->{uri} = URI->new('rabbitmq://'.$host.':'.$port);
133 0 $self->_connect;
134 0 };
135 }
136  
137 =head2 _connect
138  
139 =cut
140  
141 0 ▶sub _connect {
Subroutine _connect: not called CC=3 SCAR=24.8
142 0 my ($self) = @_;
143 0 my $real_self = $self;
144 0 weaken($self);
145  
146 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Server connecting...');
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("Server connecting...") 0 0 0
147  
148 0 ▶ unless (exists $self->{rabbitmq}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"rabbitmq"}) 0 0 0
149 0 $self->{rabbitmq} = AnyEvent::RabbitMQ->new(verbose => $self->{verbose})->load_xml_spec;
150 }
151  
152 0 $self->{closing} = 0;
153 $self->{rabbitmq}->connect(
154 0 (map { $_ => $self->{$_} } qw(host port user pass vhost timeout)),
155 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
156 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
157 0 return;
158 }
159  
160 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Server connected successfully');
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("Server connected successfully") 0 0 0
161  
162 0 foreach my $channel (values %{$self->{channel}}) {
163 0 ▶ if (exists $channel->{obj}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $channel->{"obj"}) 0 0 0
164 0 next;
165 }
166 0 $self->_open($channel);
167 }
168 },
169 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
170 0 my (undef, $fatal, $message) = @_;
171  
172 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
173 0 return;
174 }
175  
176 0 ▶ if ($fatal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fatal) { } 0 0 0
177 0 ▶ Lim::ERR and $self->{logger}->error('Server connection failure: '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Server connection failure: ' . $message) 0 0 0
178 }
179 else {
180 0 ▶ Lim::WARN and $self->{logger}->warn('Server connection failure: '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->warn('Server connection failure: ' . $message) 0 0 0
181 }
182 0 ▶ $self->{retry} = AnyEvent->timer(after => $self->{retry_interval}, cb => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
183 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
184 0 return;
185 }
186  
187 0 ▶ $self->close(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
188 0 ▶ unless ($self->{rabbitmq}->{_state}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"rabbitmq"}{"_state"}) 0 0 0
189 0 $self->{rabbitmq}->{_state} = 1;
190 }
191 0 delete $self->{rabbitmq};
192 0 $self->_connect;
193 0 });
194 0 });
195 },
196 0 ▶ on_close => sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
197 0 my ($frame) = @_;
198  
199 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
200 0 return;
201 }
202  
203 0 my $message = 'Unknown';
204 0 ▶ if (blessed $frame
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($frame) and $frame->can('method_frame') and builtin::blessed($frame->method_frame) and $frame->method_frame->can('reply_code') and $frame->method_frame->can('reply_text')) { } 0 0 0
elsif (defined $frame) { } 0 0 0
Condition0%0/12
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code")
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame)
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame")
!ll&&!rl&&r
000
MC/DC0%0/5
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")
builtin::blessed($frame) $frame->can("method_frame") builtin::blessed($frame->method_frame) $frame->method_frame->can("reply_code") $frame->method_frame->can("reply_text")
Truth table0%0/6
A and B and C and D and E
A= builtin::blessed($frame)B= $frame->can("method_frame")C= builtin::blessed($frame->method_frame)D= $frame->method_frame->can("reply_code")E= $frame->method_frame->can("reply_text")
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
205 and $frame->can('method_frame')
206 and blessed $frame->method_frame
207 and $frame->method_frame->can('reply_code')
208 and $frame->method_frame->can('reply_text'))
209 {
210 0 $message = '['.$frame->method_frame->reply_code.'] '.$frame->method_frame->reply_text;
211 }
212 elsif (defined $frame) {
213 0 $message = $frame;
214 }
215  
216 0 ▶ Lim::INFO and $self->{logger}->info('Server connection closed: '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::INFO() and $self->{"logger"}->info('Server connection closed: ' . $message) 0 0 0
217 0 ▶ $self->{retry} = AnyEvent->timer(after => $self->{retry_interval}, cb => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
218 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
219 0 return;
220 }
221  
222 0 ▶ $self->close(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
223 0 ▶ unless ($self->{rabbitmq}->{_state}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"rabbitmq"}{"_state"}) 0 0 0
224 0 $self->{rabbitmq}->{_state} = 1;
225 }
226 0 delete $self->{rabbitmq};
227 0 $self->_connect;
228 0 });
229 0 });
230 },
231 0 ▶ on_read_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
232 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
233 0 return;
234 }
235  
236 0 my ($message) = @_;
237 0 ▶ Lim::WARN and $self->{logger}->warn('Server read failure: '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->warn('Server read failure: ' . $message) 0 0 0
238 }
239 0 );
240 }
241  
242 =head2 Destroy
243  
244 =cut
245  
246 0 ▶sub Destroy {
Subroutine Destroy: not called CC=2 SCAR=17.9
Pod documented
247 0 my ($self) = @_;
248  
249 0 ▶ unless ($self->{rabbitmq}->{_state}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"rabbitmq"}{"_state"}) 0 0 0
250 0 $self->{rabbitmq}->{_state} = 1;
251 }
252 0 delete $self->{rabbitmq};
253 }
254  
255 =head2 name
256  
257 =cut
258  
259 4 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
260 4 'rabbitmq';
261 }
262  
263 =head2 uri
264  
265 =cut
266  
267 0 ▶sub uri {
Subroutine uri: not called CC=1 SCAR=6.9
Pod documented
268 0 $_[0]->{uri};
269 }
270  
271 =head2 host
272  
273 =cut
274  
275 0 ▶sub host {
Subroutine host: not called CC=1 SCAR=6.9
Pod documented
276 0 $_[0]->{host};
277 }
278  
279 =head2 port
280  
281 =cut
282  
283 0 ▶sub port {
Subroutine port: not called CC=1 SCAR=6.9
Pod documented
284 0 $_[0]->{port};
285 }
286  
287 =head2 serve
288  
289 =cut
290  
291 0 ▶sub serve {
Subroutine serve: not called CC=5 SCAR=34.0
Pod documented
292 0 my ($self, $module, $module_shortname) = @_;
293 0 my $real_self = $self;
294 0 weaken($self);
295  
296 0 ▶ unless (defined $module_shortname) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $module_shortname) 0 0 0
297 0 confess '$module_shortname not set';
298 }
299  
300 0 ▶ if (exists $self->{channel}->{$module_shortname}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"channel"}{$module_shortname}) 0 0 0
301 0 ▶ Lim::WARN and $self->{logger}->warn('Already serving '.$module_shortname);
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->warn('Already serving ' . $module_shortname) 0 0 0
302 0 return;
303 }
304  
305 0 $self->{channel}->{$module_shortname} = {
306 module => $module_shortname
307 };
308  
309 0 ▶ if ($self->{rabbitmq}->is_open) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"rabbitmq"}->is_open) 0 0 0
310 0 $self->_open($self->{channel}->{$module_shortname});
311 }
312 }
313  
314 =head2 _reopen
315  
316 =cut
317  
318 0 ▶sub _reopen {
Subroutine _reopen: not called CC=2 SCAR=17.9
319 0 my ($self, $channel) = @_;
320 0 my $real_self = $self;
321 0 weaken($self);
322  
323 0 ▶ unless (ref($channel) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $channel eq "HASH") 0 0 0
324 0 confess '$channel is not HASH';
325 }
326  
327 0 delete $channel->{obj};
328 0 delete $channel->{queue};
329 0 ▶ my $w; $w = AnyEvent->timer(after => 1, cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
330 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
331 0 return;
332 }
333  
334 0 ▶ if ($self->{rabbitmq}->is_open) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"rabbitmq"}->is_open) 0 0 0
335 0 $self->_open($channel);
336 }
337 0 $w = undef;
338 0 });
339 }
340  
341 =head2 _open
342  
343 =cut
344  
345 0 ▶sub _open {
Subroutine _open: not called CC=2 SCAR=17.9
346 0 my ($self, $channel) = @_;
347 0 my $real_self = $self;
348 0 weaken($self);
349  
350 0 ▶ unless (ref($channel) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $channel eq "HASH") 0 0 0
351 0 confess '$channel is not HASH';
352 }
353  
354 0 $channel->{obj} = 1;
355 $self->{rabbitmq}->open_channel(
356 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
357 0 my ($obj) = @_;
358  
359 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
360 0 return;
361 }
362  
363 0 ▶ unless (blessed $obj and $obj->isa('AnyEvent::RabbitMQ::Channel')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($obj) and $obj->isa("AnyEvent::RabbitMQ::Channel")) 0 0 0
Condition0%0/3
builtin::blessed($obj) and $obj->isa("AnyEvent::RabbitMQ::Channel")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($obj) and $obj->isa("AnyEvent::RabbitMQ::Channel")
builtin::blessed($obj) $obj->isa("AnyEvent::RabbitMQ::Channel")
Truth table0%0/3
A and B
A= builtin::blessed($obj)B= $obj->isa("AnyEvent::RabbitMQ::Channel")
ABresult
0X0
100
111
364 0 ▶ Lim::ERR and $self->{logger}->error('Channel open failure for '.$channel->{module}.': object given to on_success is not AnyEvent::RabbitMQ::Channel');
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel open failure for ' . $channel->{"module"} . ': object given to on_success is not AnyEvent::RabbitMQ::Channel') 0 0 0
365 0 return;
366 }
367  
368 0 $channel->{obj} = $obj;
369 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Channel opened successfully for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug('Channel opened successfully for ' . $channel->{"module"}) 0 0 0
370 0 $self->_qos($channel);
371 },
372 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
373 0 my ($message) = @_;
374  
375 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
376 0 return;
377 }
378  
379 0 ▶ Lim::ERR and $self->{logger}->error('Channel open failure for '.$channel->{module}.': '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel open failure for ' . $channel->{"module"} . ': ' . $message) 0 0 0
380 0 $self->_reopen($channel);
381 },
382 0 ▶ on_close => sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
383 0 my ($frame) = @_;
384  
385 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
386 0 return;
387 }
388  
389 0 my $message = 'Unknown';
390 0 ▶ if (blessed $frame
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")) 0 0 0
Condition0%0/12
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code")
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame)
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame")
!ll&&!rl&&r
000
MC/DC0%0/5
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")
builtin::blessed($frame) $frame->can("method_frame") builtin::blessed($frame->method_frame) $frame->method_frame->can("reply_code") $frame->method_frame->can("reply_text")
Truth table0%0/6
A and B and C and D and E
A= builtin::blessed($frame)B= $frame->can("method_frame")C= builtin::blessed($frame->method_frame)D= $frame->method_frame->can("reply_code")E= $frame->method_frame->can("reply_text")
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
391 and $frame->can('method_frame')
392 and blessed $frame->method_frame
393 and $frame->method_frame->can('reply_code')
394 and $frame->method_frame->can('reply_text'))
395 {
396 0 $message = '['.$frame->method_frame->reply_code.'] '.$frame->method_frame->reply_text;
397 }
398  
399 0 ▶ Lim::INFO and $self->{logger}->info('Channel closed for '.$channel->{module}.': '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::INFO() and $self->{"logger"}->info('Channel closed for ' . $channel->{"module"} . ': ' . $message) 0 0 0
400 0 $self->_reopen($channel);
401 },
402 0 ▶ on_return => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
403 0 my ($frame) = @_;
404  
405 0 my $message = 'Unknown';
406 0 ▶ if (blessed $frame
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")) 0 0 0
Condition0%0/12
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code")
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame)
!ll&&!rl&&r
000
builtin::blessed($frame) and $frame->can("method_frame")
!ll&&!rl&&r
000
MC/DC0%0/5
builtin::blessed($frame) and $frame->can("method_frame") and builtin::blessed($frame->method_frame) and $frame->method_frame->can("reply_code") and $frame->method_frame->can("reply_text")
builtin::blessed($frame) $frame->can("method_frame") builtin::blessed($frame->method_frame) $frame->method_frame->can("reply_code") $frame->method_frame->can("reply_text")
Truth table0%0/6
A and B and C and D and E
A= builtin::blessed($frame)B= $frame->can("method_frame")C= builtin::blessed($frame->method_frame)D= $frame->method_frame->can("reply_code")E= $frame->method_frame->can("reply_text")
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
407 and $frame->can('method_frame')
408 and blessed $frame->method_frame
409 and $frame->method_frame->can('reply_code')
410 and $frame->method_frame->can('reply_text'))
411 {
412 0 $message = '['.$frame->method_frame->reply_code.'] '.$frame->method_frame->reply_text;
413 }
414  
415 0 ▶ Lim::WARN and $self->{logger}->warn('Frame returned: '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->warn('Frame returned: ' . $message) 0 0 0
416 }
417 0 );
418 }
419  
420 =head2 _qos
421  
422 =cut
423  
424 0 ▶sub _qos {
Subroutine _qos: not called CC=4 SCAR=30.0
425 0 my ($self, $channel) = @_;
426 0 my $real_self = $self;
427 0 weaken($self);
428  
429 0 ▶ unless (ref($channel) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $channel eq "HASH") 0 0 0
430 0 confess '$channel is not HASH';
431 }
432 0 ▶ unless (blessed $channel->{obj} and $channel->{obj}->isa('AnyEvent::RabbitMQ::Channel')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")) 0 0 0
Condition0%0/3
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
builtin::blessed($channel->{"obj"}) $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
Truth table0%0/3
A and B
A= builtin::blessed($channel->{"obj"})B= $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
ABresult
0X0
100
111
433 0 confess '$channel->{obj} is not AnyEvent::RabbitMQ::Channel';
434 }
435  
436 $channel->{obj}->qos(
437 prefetch_count => $self->{prefetch_count},
438 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
439 0 my ($obj) = @_;
440  
441 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
442 0 return;
443 }
444  
445 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Channel QoS setup successfully for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug('Channel QoS setup successfully for ' . $channel->{"module"}) 0 0 0
446 0 $self->_exchange($channel);
447 },
448 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
449 0 my ($message) = @_;
450  
451 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
452 0 return;
453 }
454  
455 0 ▶ Lim::ERR and $self->{logger}->error('Channel QoS setup failure for '.$channel->{module}.': '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel QoS setup failure for ' . $channel->{"module"} . ': ' . $message) 0 0 0
456 0 $self->_reopen($channel);
457 }
458 0 );
459 }
460  
461 =head2 _exchange
462  
463 =cut
464  
465 0 ▶sub _exchange {
Subroutine _exchange: not called CC=5 SCAR=34.0
466 0 my ($self, $channel) = @_;
467 0 my $real_self = $self;
468 0 weaken($self);
469  
470 0 ▶ unless ($self->{broadcast}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"broadcast"}) 0 0 0
471 0 $self->_declare($channel);
472 0 return;
473 }
474  
475 0 ▶ unless (ref($channel) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $channel eq "HASH") 0 0 0
476 0 confess '$channel is not HASH';
477 }
478 0 ▶ unless (blessed $channel->{obj} and $channel->{obj}->isa('AnyEvent::RabbitMQ::Channel')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")) 0 0 0
Condition0%0/3
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
builtin::blessed($channel->{"obj"}) $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
Truth table0%0/3
A and B
A= builtin::blessed($channel->{"obj"})B= $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
ABresult
0X0
100
111
479 0 confess '$channel->{obj} is not AnyEvent::RabbitMQ::Channel';
480 }
481  
482 $channel->{obj}->declare_exchange(
483 exchange => $self->{exchange_prefix}.$channel->{module},
484 type => 'fanout',
485 auto_delete => 1,
486 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
487 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
488 0 return;
489 }
490  
491 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Channel exchange declared successfully for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug('Channel exchange declared successfully for ' . $channel->{"module"}) 0 0 0
492 0 $self->_declare($channel);
493 },
494 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
495 0 my ($message) = @_;
496  
497 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
498 0 return;
499 }
500  
501 0 ▶ Lim::ERR and $self->{logger}->error('Channel exchange declare failure for '.$channel->{module}.': '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel exchange declare failure for ' . $channel->{"module"} . ': ' . $message) 0 0 0
502 0 $self->_reopen($channel);
503 }
504 0 );
505 }
506  
507 =head2 _declare
508  
509 =cut
510  
511 0 ▶sub _declare {
Subroutine _declare: not called CC=5 SCAR=34.0
512 0 my ($self, $channel) = @_;
513 0 my $real_self = $self;
514 0 weaken($self);
515  
516 0 ▶ unless (ref($channel) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $channel eq "HASH") 0 0 0
517 0 confess '$channel is not HASH';
518 }
519 0 ▶ unless (blessed $channel->{obj} and $channel->{obj}->isa('AnyEvent::RabbitMQ::Channel')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")) 0 0 0
Condition0%0/3
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
builtin::blessed($channel->{"obj"}) $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
Truth table0%0/3
A and B
A= builtin::blessed($channel->{"obj"})B= $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
ABresult
0X0
100
111
520 0 confess '$channel->{obj} is not AnyEvent::RabbitMQ::Channel';
521 }
522  
523 $channel->{obj}->declare_queue(
524 ($self->{broadcast} ? (
525 exclusive => 1
526 ) : (
527 queue => $self->{queue_prefix}.$channel->{module}
528 )),
529 auto_delete => 1,
530 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
531 0 my ($method) = @_;
532  
533 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
534 0 return;
535 }
536  
537 0 ▶ if ($self->{broadcast}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'broadcast'}) { } 0 0 0
538 0 ▶ unless (blessed $method and $method->can('method_frame')
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($method) and $method->can("method_frame") and builtin::blessed($method->method_frame) and $method->method_frame->can("queue")) 0 0 0
Condition0%0/9
builtin::blessed($method) and $method->can("method_frame") and builtin::blessed($method->method_frame) and $method->method_frame->can("queue")
!ll&&!rl&&r
000
builtin::blessed($method) and $method->can("method_frame") and builtin::blessed($method->method_frame)
!ll&&!rl&&r
000
builtin::blessed($method) and $method->can("method_frame")
!ll&&!rl&&r
000
MC/DC0%0/4
builtin::blessed($method) and $method->can("method_frame") and builtin::blessed($method->method_frame) and $method->method_frame->can("queue")
builtin::blessed($method) $method->can("method_frame") builtin::blessed($method->method_frame) $method->method_frame->can("queue")
Truth table0%0/5
A and B and C and D
A= builtin::blessed($method)B= $method->can("method_frame")C= builtin::blessed($method->method_frame)D= $method->method_frame->can("queue")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
539 and blessed $method->method_frame and $method->method_frame->can('queue'))
540 {
541 0 ▶ Lim::ERR and $self->{logger}->error('Declare queue frame invalid for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Declare queue frame invalid for ' . $channel->{"module"}) 0 0 0
542 0 $self->_reopen($channel);
543 0 return;
544 }
545  
546 0 $channel->{queue} = $method->method_frame->queue;
547 }
548 else {
549 0 $channel->{queue} = $self->{queue_prefix}.$channel->{module};
550 }
551  
552 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Channel queue declared successfully for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug('Channel queue declared successfully for ' . $channel->{"module"}) 0 0 0
553 0 $self->_bind($channel);
554 },
555 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
556 0 my ($message) = @_;
557  
558 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
559 0 return;
560 }
561  
562 0 ▶ Lim::ERR and $self->{logger}->error('Channel queue declare failure for '.$channel->{module}.': '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel queue declare failure for ' . $channel->{"module"} . ': ' . $message) 0 0 0
563 0 $self->_reopen($channel);
564 }
565 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'broadcast'} ? : 0 0 0
566 }
567  
568 =head2 _bind
569  
570 =cut
571  
572 0 ▶sub _bind {
Subroutine _bind: not called CC=6 SCAR=37.4
573 0 my ($self, $channel) = @_;
574 0 my $real_self = $self;
575 0 weaken($self);
576  
577 0 ▶ unless ($self->{broadcast}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"broadcast"}) 0 0 0
578 0 $self->_consume($channel);
579 0 return;
580 }
581  
582 0 ▶ unless (ref($channel) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $channel eq "HASH") 0 0 0
583 0 confess '$channel is not HASH';
584 }
585 0 ▶ unless (blessed $channel->{obj} and $channel->{obj}->isa('AnyEvent::RabbitMQ::Channel')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")) 0 0 0
Condition0%0/3
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
builtin::blessed($channel->{"obj"}) $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
Truth table0%0/3
A and B
A= builtin::blessed($channel->{"obj"})B= $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
ABresult
0X0
100
111
586 0 confess '$channel->{obj} is not AnyEvent::RabbitMQ::Channel';
587 }
588 0 ▶ unless (defined $channel->{queue}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $channel->{"queue"}) 0 0 0
589 0 confess '$channel->{queue} is not defined';
590 }
591  
592 $channel->{obj}->bind_queue(
593 exchange => $self->{exchange_prefix}.$channel->{module},
594 queue => $channel->{queue},
595 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
596 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
597 0 return;
598 }
599  
600 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Channel queue declared successfully for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug('Channel queue declared successfully for ' . $channel->{"module"}) 0 0 0
601 0 $self->_consume($channel);
602 },
603 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
604 0 my ($message) = @_;
605  
606 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
607 0 return;
608 }
609  
610 0 ▶ Lim::ERR and $self->{logger}->error('Channel queue declare failure for '.$channel->{module}.': '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel queue declare failure for ' . $channel->{"module"} . ': ' . $message) 0 0 0
611 0 $self->_reopen($channel);
612 }
613 0 );
614 }
615  
616 =head2 _consume
617  
618 =cut
619  
620 0 ▶sub _consume {
Subroutine _consume: not called CC=5 SCAR=34.0
621 0 my ($self, $channel) = @_;
622 0 my $real_self = $self;
623 0 weaken($self);
624  
625 0 ▶ unless (ref($channel) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $channel eq "HASH") 0 0 0
626 0 confess '$channel is not HASH';
627 }
628 0 ▶ unless (blessed $channel->{obj} and $channel->{obj}->isa('AnyEvent::RabbitMQ::Channel')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")) 0 0 0
Condition0%0/3
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
builtin::blessed($channel->{"obj"}) $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
Truth table0%0/3
A and B
A= builtin::blessed($channel->{"obj"})B= $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
ABresult
0X0
100
111
629 0 confess '$channel->{obj} is not AnyEvent::RabbitMQ::Channel';
630 }
631 0 ▶ unless (defined $channel->{queue}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $channel->{"queue"}) 0 0 0
632 0 confess '$channel->{queue} is not defined';
633 }
634  
635 $channel->{obj}->consume(
636 queue => $channel->{queue},
637 no_ack => 0,
638 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
639 0 my ($method) = @_;
640  
641 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
642 0 return;
643 }
644  
645 0 ▶ unless (blessed $method and $method->can('method_frame')
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($method) and $method->can('method_frame') and builtin::blessed($method->method_frame) and $method->method_frame->can('consumer_tag')) { } 0 0 0
Condition0%0/9
builtin::blessed($method) and $method->can("method_frame") and builtin::blessed($method->method_frame) and $method->method_frame->can("consumer_tag")
!ll&&!rl&&r
000
builtin::blessed($method) and $method->can("method_frame") and builtin::blessed($method->method_frame)
!ll&&!rl&&r
000
builtin::blessed($method) and $method->can("method_frame")
!ll&&!rl&&r
000
MC/DC0%0/4
builtin::blessed($method) and $method->can("method_frame") and builtin::blessed($method->method_frame) and $method->method_frame->can("consumer_tag")
builtin::blessed($method) $method->can("method_frame") builtin::blessed($method->method_frame) $method->method_frame->can("consumer_tag")
Truth table0%0/5
A and B and C and D
A= builtin::blessed($method)B= $method->can("method_frame")C= builtin::blessed($method->method_frame)D= $method->method_frame->can("consumer_tag")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
646 and blessed $method->method_frame and $method->method_frame->can('consumer_tag'))
647 {
648 0 ▶ Lim::WARN and $self->{logger}->debug('Channel consuming for '.$channel->{module}.' but no consumer_tag found');
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->debug('Channel consuming for ' . $channel->{"module"} . ' but no consumer_tag found') 0 0 0
649 }
650 else {
651 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Channel consuming successfully for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug('Channel consuming successfully for ' . $channel->{"module"}) 0 0 0
652 0 $channel->{consumer_tag} = $method->method_frame->consumer_tag;
653 }
654 },
655 0 ▶ on_consume => sub {
Subroutine __ANON__: not called CC=21 SCAR=61.4
656 0 my ($frame) = @_;
657  
658 0 ▶ unless (defined $self and defined $channel->{obj}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self and defined $channel->{"obj"}) 0 0 0
Condition0%0/3
defined $self and defined $channel->{"obj"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self and defined $channel->{"obj"}
defined $self defined $channel->{"obj"}
Truth table0%0/3
A and B
A= defined $selfB= defined $channel->{"obj"}
ABresult
0X0
100
111
659 0 return;
660 }
661  
662 0 ▶ unless (ref($frame) eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $frame eq "HASH" and builtin::blessed($frame->{"deliver"}) and $frame->{"deliver"}->can("method_frame") and builtin::blessed($frame->{"deliver"}->method_frame) and $frame->{"deliver"}->method_frame->can("delivery_tag")) 0 0 0
Condition0%0/12
ref $frame eq "HASH" and builtin::blessed($frame->{"deliver"}) and $frame->{"deliver"}->can("method_frame") and builtin::blessed($frame->{"deliver"}->method_frame) and $frame->{"deliver"}->method_frame->can("delivery_tag")
!ll&&!rl&&r
000
ref $frame eq "HASH" and builtin::blessed($frame->{"deliver"}) and $frame->{"deliver"}->can("method_frame") and builtin::blessed($frame->{"deliver"}->method_frame)
!ll&&!rl&&r
000
ref $frame eq "HASH" and builtin::blessed($frame->{"deliver"}) and $frame->{"deliver"}->can("method_frame")
!ll&&!rl&&r
000
ref $frame eq "HASH" and builtin::blessed($frame->{"deliver"})
!ll&&!rl&&r
000
MC/DC0%0/5
ref $frame eq "HASH" and builtin::blessed($frame->{"deliver"}) and $frame->{"deliver"}->can("method_frame") and builtin::blessed($frame->{"deliver"}->method_frame) and $frame->{"deliver"}->method_frame->can("delivery_tag")
ref $frame eq "HASH" builtin::blessed($frame->{"deliver"}) $frame->{"deliver"}->can("method_frame") builtin::blessed($frame->{"deliver"}->method_frame) $frame->{"deliver"}->method_frame->can("delivery_tag")
Truth table0%0/6
A and B and C and D and E
A= ref $frame eq "HASH"B= builtin::blessed($frame->{"deliver"})C= $frame->{"deliver"}->can("method_frame")D= builtin::blessed($frame->{"deliver"}->method_frame)E= $frame->{"deliver"}->method_frame->can("delivery_tag")
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
663 and blessed $frame->{deliver} and $frame->{deliver}->can('method_frame')
664 and blessed $frame->{deliver}->method_frame and $frame->{deliver}->method_frame->can('delivery_tag'))
665 {
666 0 ▶ Lim::ERR and $self->{logger}->error('Consume request invalid, may go unacked');
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error("Consume request invalid, may go unacked") 0 0 0
667 0 return;
668 }
669  
670 0 ▶ unless (blessed $frame->{body} and $frame->{body}->can('payload')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($frame->{"body"}) and $frame->{"body"}->can("payload")) 0 0 0
Condition0%0/3
builtin::blessed($frame->{"body"}) and $frame->{"body"}->can("payload")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($frame->{"body"}) and $frame->{"body"}->can("payload")
builtin::blessed($frame->{"body"}) $frame->{"body"}->can("payload")
Truth table0%0/3
A and B
A= builtin::blessed($frame->{"body"})B= $frame->{"body"}->can("payload")
ABresult
0X0
100
111
671 0 ▶ Lim::ERR and $self->{logger}->error('Consume request invalid, no payload');
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error("Consume request invalid, no payload") 0 0 0
672 0 return;
673 }
674  
675 0 my $headers = HTTP::Headers->new;
676 0 ▶ if (blessed $frame->{header} and $frame->{header}->can('headers') and ref($frame->{header}->headers) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("headers") and ref $frame->{"header"}->headers eq "HASH") 0 0 0
Condition0%0/6
builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("headers") and ref $frame->{"header"}->headers eq "HASH"
!ll&&!rl&&r
000
builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("headers")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("headers") and ref $frame->{"header"}->headers eq "HASH"
builtin::blessed($frame->{"header"}) $frame->{"header"}->can("headers") ref $frame->{"header"}->headers eq "HASH"
Truth table0%0/4
A and B and C
A= builtin::blessed($frame->{"header"})B= $frame->{"header"}->can("headers")C= ref $frame->{"header"}->headers eq "HASH"
ABCresult
0XX0
10X0
1100
1111
677 0 $headers->header(%{$frame->{header}->headers});
678 }
679 my $request = HTTP::Request->new(
680 GET => '/'.$channel->{module},
681 $headers,
682 $frame->{body}->payload
683 0 );
684  
685 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('RabbitMQ request: ', $request->as_string);
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("RabbitMQ request: ", $request->as_string) 0 0 0
686  
687 my $cb = Lim::RPC::Callback->new(
688 0 ▶ cb => sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
689 0 my ($response) = @_;
690  
691 0 ▶ unless (defined $self and defined $channel->{obj}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self and defined $channel->{"obj"}) 0 0 0
Condition0%0/3
defined $self and defined $channel->{"obj"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self and defined $channel->{"obj"}
defined $self defined $channel->{"obj"}
Truth table0%0/3
A and B
A= defined $selfB= defined $channel->{"obj"}
ABresult
0X0
100
111
692 0 return;
693 }
694  
695 0 ▶ if (!$self->{broadcast}
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"broadcast"} and builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("reply_to") and builtin::blessed($response) and $response->isa("HTTP::Response")) 0 0 0
Condition0%0/12
not $self->{"broadcast"} and builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("reply_to") and builtin::blessed($response) and $response->isa("HTTP::Response")
!ll&&!rl&&r
000
not $self->{"broadcast"} and builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("reply_to") and builtin::blessed($response)
!ll&&!rl&&r
000
not $self->{"broadcast"} and builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("reply_to")
!ll&&!rl&&r
000
not $self->{"broadcast"} and builtin::blessed($frame->{"header"})
!ll&&!rl&&r
000
MC/DC0%0/5
not $self->{"broadcast"} and builtin::blessed($frame->{"header"}) and $frame->{"header"}->can("reply_to") and builtin::blessed($response) and $response->isa("HTTP::Response")
not $self->{"broadcast"} builtin::blessed($frame->{"header"}) $frame->{"header"}->can("reply_to") builtin::blessed($response) $response->isa("HTTP::Response")
Truth table0%0/6
not(A) and B and C and D and E
A= not $self->{"broadcast"}B= builtin::blessed($frame->{"header"})C= $frame->{"header"}->can("reply_to")D= builtin::blessed($response)E= $response->isa("HTTP::Response")
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
696 and blessed $frame->{header}
697 and $frame->{header}->can('reply_to')
698 and blessed($response)
699 and $response->isa('HTTP::Response'))
700 {
701 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('RabbitMQ response: ', $response->as_string);
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("RabbitMQ response: ", $response->as_string) 0 0 0
702  
703 $channel->{obj}->publish(
704 exchange => '',
705 routing_key => $frame->{header}->reply_to,
706 0 header => {
707 headers => {
708 'X-Lim-Code' => $response->code,
709 'Content-Type' => $response->header('Content-Type')
710 }
711 },
712 body => $response->content
713 );
714 }
715  
716 $channel->{obj}->ack(
717 delivery_tag => $frame->{deliver}->method_frame->delivery_tag
718 0 );
719 },
720 0 ▶ reset_timeout => sub {
Subroutine __ANON__: not called CC=1 SCAR=0.0
721 }
722 0 );
723  
724 0 foreach my $protocol ($self->protocols) {
725 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Trying protocol ', $protocol->name);
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("Trying protocol ", $protocol->name) 0 0 0
726 0 ▶ if ($protocol->handle($cb, $request, $self)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($protocol->handle($cb, $request, $self)) 0 0 0
727 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Request handled by protocol ', $protocol->name);
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("Request handled by protocol ", $protocol->name) 0 0 0
728 0 return;
729 }
730 }
731  
732 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Did not find any protocol handler for request');
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug("Did not find any protocol handler for request") 0 0 0
733  
734 # TODO: reject rabbitmq frame?
735  
736 $channel->{obj}->ack(
737 delivery_tag => $frame->{deliver}->method_frame->delivery_tag
738 0 );
739 },
740 0 ▶ on_cancel => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
741 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
742 0 return;
743 }
744  
745 0 ▶ if ($self->{closing}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'closing'}) { } 0 0 0
746 0 ▶ Lim::RPC_DEBUG and $self->{logger}->debug('Channel cancelled for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and $self->{"logger"}->debug('Channel cancelled for ' . $channel->{"module"}) 0 0 0
747 }
748 else {
749 0 ▶ Lim::ERR and $self->{logger}->error('Channel cancelled for '.$channel->{module});
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel cancelled for ' . $channel->{"module"}) 0 0 0
750 0 $self->_reopen($channel);
751 }
752 },
753 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
754 0 my ($message) = @_;
755  
756 0 ▶ unless (defined $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self) 0 0 0
757 0 return;
758 }
759  
760 0 ▶ Lim::ERR and $self->{logger}->error('Channel consume failure for '.$channel->{module}.': '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error('Channel consume failure for ' . $channel->{"module"} . ': ' . $message) 0 0 0
761 0 $self->_reopen($channel);
762 }
763 0 );
764 }
765  
766 =head2 close
767  
768 =cut
769  
770 0 ▶sub close {
Subroutine close: not called CC=7 SCAR=40.3
Pod documented
771 0 my ($self, $cb) = @_;
772 0 my $real_self = $self;
773 0 weaken($self);
774 0 my $queue_prefix = $self->{queue_prefix};
775  
776 0 ▶ unless (ref($cb) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $cb eq "CODE") 0 0 0
777 0 confess '$cb is not CODE';
778 }
779  
780 0 my $cv = AnyEvent->condvar;
781 0 ▶ $cv->begin(sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
782 0 $cb->();
783 0 $cv = undef;
784 0 });
785  
786 0 $self->{closing} = 1;
787 0 foreach my $channel (values %{$self->{channel}}) {
788 0 ▶ unless (blessed $channel->{obj} and $channel->{obj}->isa('AnyEvent::RabbitMQ::Channel') and defined $channel->{queue}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel") and defined $channel->{"queue"}) 0 0 0
Condition0%0/6
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel") and defined $channel->{"queue"}
!ll&&!rl&&r
000
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($channel->{"obj"}) and $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel") and defined $channel->{"queue"}
builtin::blessed($channel->{"obj"}) $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel") defined $channel->{"queue"}
Truth table0%0/4
A and B and C
A= builtin::blessed($channel->{"obj"})B= $channel->{"obj"}->isa("AnyEvent::RabbitMQ::Channel")C= defined $channel->{"queue"}
ABCresult
0XX0
10X0
1100
1111
789 0 next;
790 }
791  
792 0 ▶ if ($channel->{consumer_tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($channel->{"consumer_tag"}) 0 0 0
793 0 $cv->begin;
794 $channel->{obj}->cancel(
795 consumer_tag => $channel->{consumer_tag},
796 0 ▶ on_success => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
797 0 ▶ Lim::RPC_DEBUG and defined $self and $self->{logger}->debug('Channel cancel successfully');
Branch: 1 branch
BranchTrueFalseTotal
Lim::RPC_DEBUG() and defined $self and $self->{"logger"}->debug("Channel cancel successfully") 0 0 0
Condition0%0/3
Lim::RPC_DEBUG() and defined $self
!ll&&!rl&&r
000
MC/DC0%0/2
Lim::RPC_DEBUG() and defined $self
Lim::RPC_DEBUG() defined $self
Truth table0%0/3
A and B
A= Lim::RPC_DEBUG()B= defined $self
ABresult
0X0
100
111
798 0 $cv->end;
799 },
800 0 ▶ on_failure => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
801 0 my ($message) = @_;
802  
803 0 ▶ Lim::ERR and defined $self and $self->{logger}->error('Channel cancel failure: '.$message);
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and defined $self and $self->{"logger"}->error('Channel cancel failure: ' . $message) 0 0 0
Condition0%0/3
Lim::ERR() and defined $self
!ll&&!rl&&r
000
MC/DC0%0/2
Lim::ERR() and defined $self
Lim::ERR() defined $self
Truth table0%0/3
A and B
A= Lim::ERR()B= defined $self
ABresult
0X0
100
111
804 0 $cv->end;
805 }
806 0 );
807 }
808 }
809 0 $cv->end;
810  
811 0 $self;
812 }
813  
814 =head1 AUTHOR
815  
816 Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >>
817  
818 =head1 BUGS
819  
820 Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>.
821  
822 =head1 SUPPORT
823  
824 You can find documentation for this module with the perldoc command.
825  
826 perldoc Lim
827  
828 You can also look for information at:
829  
830 =over 4
831  
832 =item * Lim issue tracker (report bugs here)
833  
834 L<https://github.com/jelu/lim/issues>
835  
836 =back
837  
838 =head1 ACKNOWLEDGEMENTS
839  
840 =head1 LICENSE AND COPYRIGHT
841  
842 Copyright 2012-2013 Jerry Lundström.
843  
844 This program is free software; you can redistribute it and/or modify it
845 under the terms of either: the GNU General Public License as published
846 by the Free Software Foundation; or the Artistic License.
847  
848 See http://dev.perl.org/licenses/ for more information.
849  
850  
851 =cut
852  
853 5 1; # End of Lim::RPC::Transport::RabbitMQ
« Lim/RPC/Transport/Clients.pm ↑ Summary Lim/RPC.pm »