File: Null.pm

package info (click to toggle)
libmetrics-any-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 220 kB
  • sloc: perl: 1,295; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#  You may distribute under the terms of either the GNU General Public License
#  or the Artistic License (the same terms as Perl itself)
#
#  (C) Paul Evans, 2020 -- leonerd@leonerd.org.uk

package Metrics::Any::Adapter::Null 0.10;

use v5.14;
use warnings;

=head1 NAME

C<Metrics::Any::Adapter::Null> - a metrics reporting adapter which does nothing

=head1 DESCRIPTION

This L<Metrics::Any> adapter type contains an empty stub implementation of the
adapter API, allowing a module to invoke methods on its metrics collector that
do not do anything.

A program would run with this adapter by default unless it has requested a
different one, via the C<use Metrics::Any::Adapter> statement.

This adapter type claims to support batch mode, though the reporting callback
will never be invoked.

=cut

sub new
{
   my $class = shift;
   return bless {}, $class;
}

# All of these are empty methods
foreach my $method (qw(
   make_counter      inc_counter_by
   make_distribution report_distribution
   make_gauge        inc_gauge_by  set_gauge_to
   make_timer        report_timer
)) {
   no strict 'refs';
   *$method = sub {};
}

# Batch mode is supported but does nothing
use constant HAVE_BATCH_MODE => 1;
sub add_batch_mode_callback {}

=head1 AUTHOR

Paul Evans <leonerd@leonerd.org.uk>

=cut

0x55AA;