2 unstable releases
Uses old Rust 2015
0.2.0 | Nov 24, 2017 |
---|---|
0.1.0 | Mar 2, 2017 |
#8 in #graphite
61KB
649 lines
Carbon Bindings for Tokio
Status: Beta
Documentation | Github | Crate
A library to submit data to carbon (graphite). Works in asynchronous main loop using tokio.
Features:
- Pluggable name resolution (service discovery)
- Reconnects to the new host(s) on the fly
- Connects to multiple hosts and duplicates records if name resolves to multiple hosts.
License
Licensed under either of
- Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
Carbon client protocol implementation
Documentation | Github | Crate
High Level Interface
let (carbon, init) = Carbon::new(&Config::new().done());
init.connect_to(resolver.subscribe("localhost:2003"), &handle);
// now you can submit metrics
carbon.add_metric("my.metric", 10);
This allows protocol to:
- Establish connection to all addressses address resolves too
- Reconnect in case of failure
- Reconnect to new host(s) when IPs the DNS name resolves to changes
See examples for more full examples.
Lower Level Interface
In case you don't want to use connection pooling, you may connect carbon instance to a specific connection:
use tk_carbon::{Carbon, Config};
let (carbon, init) = Carbon::new(&Config::new().done());
handle.spawn(TcpStream::connect(&addr, &handle)
.and_then(move |sock| init.from_connection(sock, &handle2))
.map_err(|e| unimplemented!()));
// use carbon the same way as above
carbon.add_metric("my.metric", 10);
General
Carbon
object is the same for connection pool and
raw interface and may be used from any thread as long as the tokio loop
running the networking code is still alive.
You don't have to wait until connection is established to send metrics,
they will be buffered up till configuration limit
(see docs on Config
)
Dependencies
~7MB
~111K SLoC