File: future-io-server.pl

package info (click to toggle)
libnet-prometheus-perl 0.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: perl: 1,847; makefile: 8
file content (30 lines) | stat: -rw-r--r-- 638 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
#!/usr/bin/perl

use v5.14;
use warnings;

use Net::Prometheus;

use Metrics::Any::Adapter 'Prometheus';

use constant LISTEN_PORT => 8200;

# Try to find a usable Future::IO impl
foreach (qw( UV Glib IOAsync Tickit )) {
   ( my $file = ( my $class = "Future::IO::Impl::$_" ) . ".pm" ) =~ s(::)(/)g;
   eval { require $file } and do {
      print STDERR "Using $class\n";
      last;
   };
}

my $client = Net::Prometheus->new;

$client->new_gauge(
   name => "ten",
   help => "The number ten",
)->set( 10 );

printf STDERR "Serving metrics on http://[::]:%d\n", LISTEN_PORT;

$client->export_to_Future_IO( port => LISTEN_PORT )->await;