Net-Statsd-Lite
view release on metacpan or search on metacpan
lib/Net/Statsd/Lite.pm view on Meta::CPAN
package Net::Statsd::Lite;
# ABSTRACT: A lightweight StatsD client that supports multimetric packets
use v5.20;
use Moo 1.000000;
use Devel::StrictMode;
use IO::Socket 1.18 ();
use MooX::TypeTiny;
use Ref::Util qw/ is_plain_hashref /;
use Scalar::Util qw/ refaddr /;
use Sub::Quote qw/ quote_sub /;
use Sub::Util 1.40 qw/ set_subname /;
use Types::Common 2.000000 qw/ Bool Enum InstanceOf Int IntRange NonEmptySimpleStr
NumRange PositiveInt PositiveOrZeroInt PositiveOrZeroNum SimpleStr StrMatch
/;
use namespace::autoclean;
use experimental qw/ signatures /;
# RECOMMEND PREREQ: Ref::Util::XS
# RECOMMEND PREREQ: Type::Tiny::XS
our $VERSION = 'v0.8.0';
has host => (
is => 'ro',
isa => NonEmptySimpleStr,
default => '127.0.0.1',
);
has port => (
is => 'ro',
isa => IntRange[ 0, 65535 ],
default => 8125,
);
has proto => (
is => 'ro',
isa => Enum [qw/ tcp udp /],
default => 'udp',
);
has prefix => (
is => 'ro',
isa => SimpleStr,
default => '',
);
has autoflush => (
is => 'ro',
isa => Bool,
default => 1,
);
my %Buffers;
has max_buffer_size => (
is => 'ro',
isa => PositiveInt,
default => 512,
);
has _socket => (
is => 'lazy',
isa => InstanceOf ['IO::Socket::INET'],
builder => sub($self) {
my $sock = IO::Socket::INET->new(
PeerAddr => $self->host,
PeerPort => $self->port,
Proto => $self->proto,
) or die "Failed to initialize socket: $!";
return $sock;
},
handles => { _send => 'send' },
( run in 3.828 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )