influx_db_client/lib.rs
1//! # InfluxDB Client
2//! InfluxDB is an open source time series database with no external dependencies.
3//! It's useful for recording metrics, events, and performing analytics.
4//!
5//! ## Usage
6//!
7//! ### http
8//!
9//! ```Rust
10//! use influx_db_client::{Client, Point, Points, Value, Precision};
11//!
12//! // default with "http://127.0.0.1:8086", db with "test"
13//! let client = Client::default().set_authentication("root", "root");
14//!
15//! let mut point = point!("test1");
16//! let point = point
17//! .add_field("foo", Value::String("bar".to_string()))
18//! .add_field("integer", Value::Integer(11))
19//! .add_field("float", Value::Float(22.3))
20//! .add_field("'boolean'", Value::Boolean(false));
21//!
22//! let point1 = Point::new("test1")
23//! .add_tag("tags", Value::String(String::from("\\\"fda")))
24//! .add_tag("number", Value::Integer(12))
25//! .add_tag("float", Value::Float(12.6))
26//! .add_field("fd", Value::String("'3'".to_string()))
27//! .add_field("quto", Value::String("\\\"fda".to_string()))
28//! .add_field("quto1", Value::String("\"fda".to_string()));
29//!
30//! let points = points!(point1, point);
31//!
32//! // if Precision is None, the default is second
33//! // Multiple write
34//! client.write_points(points, Some(Precision::Seconds), None).unwrap();
35//!
36//! // query, it's type is Option<Vec<Node>>
37//! let res = client.query("select * from test1", None).unwrap();
38//! println!("{:?}", res.unwrap()[0].series)
39//! ```
40//!
41//! ### udp
42//!
43//! ```Rust
44//! use influx_db_client::{UdpClient, Point, Value};
45//!
46//! let mut udp = UdpClient::new("127.0.0.1:8089".parse().unwrap());
47//! udp.add_host("127.0.0.1:8090".parse().unwrap());
48//!
49//! let mut point = point!("test");
50//! point.add_field("foo", Value::String(String::from("bar")));
51//!
52//! udp.write_point(point).unwrap();
53//! ```
54
55#![deny(warnings)]
56#![deny(missing_docs)]
57
58/// All API on influxdb client, Including udp, http
59pub mod client;
60/// Error module
61pub mod error;
62/// Points and Query Data Deserialize
63pub mod keys;
64/// Serialization module
65pub(crate) mod serialization;
66
67pub use client::{Client, UdpClient};
68pub use error::Error;
69pub use keys::{ChunkedQuery, Node, Point, Points, Precision, Query, Series, Value};
70
71pub use reqwest;