AnyEvent-Graphite

 view release on metacpan or  search on metacpan

lib/AnyEvent/Graphite.pm  view on Meta::CPAN

    bless {
        host => $host,
        port => $port,
        %args,
    }, $class;
}

sub send {
    my($self, $id, $value, $ts) = @_;
    return unless (defined($id) && defined($value));
    $ts ||= AE::now; # cached time() from the framework
    if($self->{conn}) {
        $self->{conn}->push_write(join(" ", $id, $value, $ts) . "\n");
    } else {
        my $handle; $handle = new AnyEvent::Handle
            connect => [$self->{host} => $self->{port}],
            on_error => sub {
                # we have no reason to exist w/out a connection.
                die "Unable to connect to Graphite server at $self->{host}:$self->{port}: $!\n";
            };
        $self->{conn} = $handle;



( run in 0.533 second using v1.01-cache-2.11-cpan-524268b4103 )