| 1 | # ABSTRACT: Backend base class for Net::Statsd::Server | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | package Net::Statsd::Server::Backend; | ||||||||||||||||||||
| 4 | { | ||||||||||||||||||||
| 5 | 4 | $Net::Statsd::Server::Backend::VERSION = '0.19'; | |||||||||||||||||||
| 6 | } | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | # Use statements {{{ | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 4 | ▶ | use Time::HiRes (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | # }}} | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | sub new { | ||||||||||||||||||||
| 17 | 1 | ▶ | my ($class, $startup_time, $config) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | my $name = name($class); | |||||||||||||||||||
| 20 | 1 | ▶ | $class = ref $class || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | my $self = { | ||||||||||||||||||||
| 23 | lastFlush => $startup_time, | ||||||||||||||||||||
| 24 | lastException => $startup_time, | ||||||||||||||||||||
| 25 | 1 | config => $config->{$name}, | |||||||||||||||||||
| 26 | }; | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 1 | bless $self, $class; | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | # Subclass way of doing special things | ||||||||||||||||||||
| 31 | 1 | $self->init($startup_time, $config); | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 1 | return $self; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | sub config { | ||||||||||||||||||||
| 37 | 0 | ▶ | $_[0]->{config}; | ||||||||||||||||||
|
Subroutine
config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | sub name { | ||||||||||||||||||||
| 41 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 1 | ▶ | my $backend_name = ref($self) || $self; | ||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 44 | 1 | $backend_name =~ s{^ .* :: ([^:]+) $}{$1}x; | |||||||||||||||||||
| 45 | 1 | $backend_name = lc $backend_name; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 1 | return $backend_name; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | sub flush { | ||||||||||||||||||||
| 51 | 0 | ▶ | die "Base class. Implement your own flush()"; | ||||||||||||||||||
|
Subroutine
flush: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | sub status { | ||||||||||||||||||||
| 55 | 0 | ▶ | die "Base class. Implement your own status()"; | ||||||||||||||||||
|
Subroutine
status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | sub since { | ||||||||||||||||||||
| 59 | 0 | ▶ | my ($self, $hires_ts) = @_; | ||||||||||||||||||
|
Subroutine
since: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 60 | 0 | return int(Time::HiRes::tv_interval($hires_ts)); | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 4 | 1; | |||||||||||||||||||