line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Backend base class for Net::Statsd::Server |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::Statsd::Server::Backend; |
4
|
|
|
|
|
|
|
$Net::Statsd::Server::Backend::VERSION = '0.20'; |
5
|
|
|
|
|
|
|
# Use statements {{{ |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
16
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
110
|
|
8
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
69
|
|
9
|
4
|
|
|
4
|
|
11
|
use Time::HiRes (); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
781
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# }}} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
1
|
|
|
1
|
0
|
380
|
my ($class, $startup_time, $config) = @_; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
3
|
my $name = name($class); |
17
|
1
|
|
33
|
|
|
3
|
$class = ref $class || $class; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $self = { |
20
|
|
|
|
|
|
|
lastFlush => $startup_time, |
21
|
|
|
|
|
|
|
lastException => $startup_time, |
22
|
1
|
|
|
|
|
4
|
config => $config->{$name}, |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
1
|
bless $self, $class; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Subclass way of doing special things |
28
|
1
|
|
|
|
|
3
|
$self->init($startup_time, $config); |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
1
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub config { |
34
|
0
|
|
|
0
|
0
|
0
|
$_[0]->{config}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub name { |
38
|
1
|
|
|
1
|
0
|
1
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
33
|
|
|
6
|
my $backend_name = ref($self) || $self; |
41
|
1
|
|
|
|
|
6
|
$backend_name =~ s{^ .* :: ([^:]+) $}{$1}x; |
42
|
1
|
|
|
|
|
13
|
$backend_name = lc $backend_name; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
2
|
return $backend_name; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub flush { |
48
|
0
|
|
|
0
|
0
|
|
die "Base class. Implement your own flush()"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub status { |
52
|
0
|
|
|
0
|
0
|
|
die "Base class. Implement your own status()"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub since { |
56
|
0
|
|
|
0
|
0
|
|
my ($self, $hires_ts) = @_; |
57
|
0
|
|
|
|
|
|
return int(Time::HiRes::tv_interval($hires_ts)); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |