Lim/RPC/Transport/Client/RabbitMQ.pm

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