File Coverage

blib/lib/Riemann/Client/Transport/UDP.pm
Criterion Covered Total %
statement 9 15 60.0
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 12 24 50.0


line stmt bran cond sub pod time code
1             package # hide from CPAN
2             Riemann::Client::Transport::UDP;
3              
4 2     2   18 use Moo;
  2         7  
  2         16  
5              
6 2     2   1023 use Riemann::Client::Protocol;
  2         6  
  2         91  
7              
8             extends 'Riemann::Client::Transport';
9              
10 2     2   16 use constant MAX_DTGRM_SIZE => 16384;
  2         6  
  2         377  
11              
12             sub send {
13 0     0 0   my ($self, $msg) = @_;
14              
15             # Encode the message
16 0           my $encoded = Msg->encode($msg);
17              
18 0 0         if (length $encoded > MAX_DTGRM_SIZE) {
19 0           die 'Message too long';
20             }
21              
22             # Write to the socket
23 0           my $sock = $self->socket;
24 0 0         $sock->send($encoded) or die $!;
25             }
26              
27             1;