Passing/Output/Socket/UDP.pm

filter: Statementstmt 65.0% 13 / 20 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 50.0% 1 / 2 totaltotal 54.8% 17 / 31 SCAR 8.2
CC
2
Cov
59%
_build_handle
6.0
_default_port
2.0
BUILD
2.0
CRAP 2.3
« Passing/Role/Input.pm ↑ Summary Passing/Filter/Decoder/Gzip.pm »
1 package Message::Passing::Output::Socket::UDP;
2 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 with qw/
7 Message::Passing::Role::Output
8 Message::Passing::Role::HasHostnameAndPort
9 Message::Passing::Role::HasErrorChain
10 /;
11  
12 1 has '+port' => (
13 required => 1,
14 );
15  
16 0 ▶sub _default_port { die "You must supply a port #" }
Subroutine _default_port: not called CC=1 SCAR=6.9
17  
18 1 has handle => (
19 is => 'ro',
20 builder => '_build_handle',
21 lazy => 1,
22 );
23  
24 sub BUILD {
25 0 ▶ my $self = shift;
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
26 0 $self->handle;
27 }
28  
29 sub _build_handle {
30 0 ▶ my $self = shift;
Subroutine _build_handle: not called CC=2 SCAR=17.9
31 0 ▶ IO::Socket::INET->new(
Branch: 1 branch
BranchTrueFalseTotal
"IO::Socket::INET"->new("Proto", "udp", "PeerAddr", $self->hostname, "PeerPort", $self->port) or die "Could not create UDP socket: $!\n" 0 0 0
32 Proto => 'udp',
33 PeerAddr => $self->hostname,
34 PeerPort => $self->port,
35 ) or die "Could not create UDP socket: $!\n";
36 }
37  
38 sub consume {
39 0 ▶ my ($self, $msg) = @_;
Subroutine consume: not called CC=1 SCAR=6.9
Pod documented
40 0 $self->handle->send($msg);
41 }
42  
43 1 1;
44  
45 =head1 NAME
46  
47 Message::Passing::Output::Socket::UDP
48  
49 =head1 DESCRIPTION
50  
51 Outputs messages to a UDP socket.
52  
53 =head1 METHODS
54  
55 =head2 consume
56  
57 Consumes a message by emitting it over UDP.
58  
59 =head1 AUTHOR, COPYRIGHT AND LICENSE
60  
61 See L<Message::Passing>.
62  
63 =cut
« Passing/Role/Input.pm ↑ Summary Passing/Filter/Decoder/Gzip.pm »