NAME Mojo::Graphite::Writer - A non-blocking Graphite metric writer using the Mojo stack SYNOPSIS my $graphite = Mojo::Graphite::Writer->new(address => 'graphite.myhost.com'); my $time = time; $graphite->write( "my.metric.one 1 $time", "my.metric.two 2 $time", ... ); DESCRIPTION Mojo::Graphite::Writer is a non-blocking client for feeding data to the Graphite metrics collector. This simple module is meant to aid in batching and queuing writes to the server. This is still a work-in-progress, however the author uses it in work applications so every effort will be made to keep the api reasonably stable while improving where possible. ATTRIBUTES Mojo::Graphite::Writer inherits all attributes from Mojo::Base and implements the following new ones. address Address of the target Graphite server. Required. batch_size The number of metrics to send in each write batch. Default is 100. port Port of the target Graphite server. Default is 2003. METHODS Mojo::Graphite::Writer inherits all methods from Mojo::Base and implements the following new ones. close Close the current connection to "address". connect Open a new connection to "address":"port" using "client" in Mojo::IOLoop. Any additional arguments are passed through to that method. Returns a Mojo::Promise that resolves with the Mojo::IOLoop::Stream object of the connection. Note that if the client is already connected, the promise is resolved again with the same stream and will until that stream is closed. In this way, for simple connections, you may simple call "write" while for more complex ones, you may open the connction using this method with additional arguments if needed and then call "write" later. write Write metrics to the "connect"-ed graphite server. Metrics are queued and written to the server in a non-blocking way, in the order that "write" is called. Metrics are strings of the form path value time as documented as "the plaintext protocol" . Each string is one metric. It will be line-ending normalized, no newline is required. Writes are batched in groups of size "batch_size". If the writer is not already connected, calling write will implicitly call "connect". Returns a Mojo::Promise that will be resolved when the metrics passed in this write call are written. The promise is rejected if any write in the write queue fails, even if it is not from the write call. FUTURE WORK This module is still in early development. Future work will include * Passing structures to "write" and handling the formatting * Possibly a blocking api, though this is questionable SEE ALSO * https://graphite.readthedocs.io/en/latest/ THANKS This module's development was sponsored by ServerCentral Turing Group . SOURCE REPOSITORY http://github.com/jberger/Mojo-Redfish-Client AUTHOR Joel Berger, CONTRIBUTORS None yet. THANKS Mohammad S Anwar (manwar) COPYRIGHT AND LICENSE Copyright (C) 2019 by "AUTHOR" and "CONTRIBUTORS" This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.