ZeroMQ/Reply.pm

filter: Statementstmt 87.5% 14 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 90.9% 20 / 22 CC 1 SCAR 0.5
CC
1
Cov
88%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« ZeroMQ/Publish.pm ↑ Summary ZeroMQ/Subscribe.pm »
1 package AnyEvent::ZeroMQ::Reply;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $AnyEvent::ZeroMQ::Reply::VERSION = '0.01';
4 }
5 # ABSTRACT: Non-blocking OO abstraction over ZMQ_REP request/reply sockets
6 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use true;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 0 ▶use ZeroMQ::Raw::Constants qw(ZMQ_REP);
Subroutine BEGIN: called CC=1 SCAR=2.6
11  
12 with 'AnyEvent::ZeroMQ::Role::WithHandle' =>
13 { socket_type => ZMQ_REP, socket_direction => '' };
14  
15 has 'on_request' => (
16 is => 'ro',
17 isa => 'CodeRef',
18 required => 1,
19 );
20  
21 after 'BUILD' => sub {
22 my $self = shift;
23 my $h = $self->handle;
24  
25 weaken $self;
26 $h->on_read(sub {
27 my ($h, $msg) = @_;
28 my $res = $self->on_request->($self, $msg);
29 $h->push_write($res);
30 });
31 };
32  
33 with 'AnyEvent::ZeroMQ::Handle::Role::Generic';
34  
35 __PACKAGE__->meta->make_immutable;
36  
37 __END__
« ZeroMQ/Publish.pm ↑ Summary ZeroMQ/Subscribe.pm »