| 1 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | package Measure::Everything::Adapter::InfluxDB::UDP; | ||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: A Measure::Everything adapter to feed InfluxDB through UDP. | ||||||||||||||||||||||||||||||||||
| 6 | 7 | $Measure::Everything::Adapter::InfluxDB::UDP::VERSION = '0.01'; | |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use base qw(Measure::Everything::Adapter::Base); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use InfluxDB::LineProtocol qw(data2line); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | sub init { | ||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 14 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 15 | 6 | my %config = @_; | |||||||||||||||||||||||||||||||||
| 16 | my $socket = IO::Socket::INET->new( | ||||||||||||||||||||||||||||||||||
| 17 | PeerAddr => $config{host} || $config{addr} || 'localhost', | ||||||||||||||||||||||||||||||||||
| 18 | 6 | ▶ | PeerPort => $config{port} || 8089, | ||||||||||||||||||||||||||||||||
|
Condition42%3/7
$config{'host'} || $config{'addr'} || 'localhost'
$config{"host"} or $config{"addr"}
$config{'port'} || 8089
MC/DC0%0/2
$config{'host'} || $config{'addr'} || 'localhost'
$config{"host"}
$config{"addr"}
MC/DC0%0/1
$config{'port'} || 8089
$config{'port'}
Truth table33%1/3
A or B
A= $config{"host"}B= $config{"addr"}
Truth table50%1/2
A
A= $config{'port'}
| |||||||||||||||||||||||||||||||||||
| 19 | Proto => 'udp', | ||||||||||||||||||||||||||||||||||
| 20 | ReuseAddr => 1, | ||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||
| 22 | 6 | $self->{socket} = $socket; | |||||||||||||||||||||||||||||||||
| 23 | 6 | return $self; | |||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 6 | ▶ | sub write { | ||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 27 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 28 | 6 | my $line = data2line(@_); | |||||||||||||||||||||||||||||||||
| 29 | 6 | return $self->{socket}->send( $line ); | |||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 7 | 1; | |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | __END__ | ||||||||||||||||||||||||||||||||||