|
7 | 7 | //! ### http |
8 | 8 | //! |
9 | 9 | //! ```Rust |
10 | | -//! #[macro_use] |
11 | | -//! extern crate influx_db_client; |
12 | | -//! |
13 | 10 | //! use influx_db_client::{Client, Point, Points, Value, Precision}; |
14 | 11 | //! |
15 | | -//! fn main() { |
16 | | -//! // default with "http://127.0.0.1:8086", db with "test" |
17 | | -//! let client = Client::default().set_authentication("root", "root"); |
18 | | -//! |
19 | | -//! let mut point = point!("test1"); |
20 | | -//! point |
21 | | -//! .add_field("foo", Value::String("bar".to_string())) |
22 | | -//! .add_field("integer", Value::Integer(11)) |
23 | | -//! .add_field("float", Value::Float(22.3)) |
24 | | -//! .add_field("'boolean'", Value::Boolean(false)); |
25 | | -//! |
26 | | -//! let point1 = Point::new("test1") |
27 | | -//! .add_tag("tags", Value::String(String::from("\\\"fda"))) |
28 | | -//! .add_tag("number", Value::Integer(12)) |
29 | | -//! .add_tag("float", Value::Float(12.6)) |
30 | | -//! .add_field("fd", Value::String("'3'".to_string())) |
31 | | -//! .add_field("quto", Value::String("\\\"fda".to_string())) |
32 | | -//! .add_field("quto1", Value::String("\"fda".to_string())) |
33 | | -//! .to_owned(); |
34 | | -//! |
35 | | -//! let points = points!(point1, point); |
36 | | -//! |
37 | | -//! // if Precision is None, the default is second |
38 | | -//! // Multiple write |
39 | | -//! let _ = client.write_points(points, Some(Precision::Seconds), None).unwrap(); |
40 | | -//! |
41 | | -//! // query, it's type is Option<Vec<Node>> |
42 | | -//! let res = client.query("select * from test1", None).unwrap(); |
43 | | -//! println!("{:?}", res.unwrap()[0].series) |
44 | | -//! } |
| 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) |
45 | 39 | //! ``` |
46 | 40 | //! |
47 | 41 | //! ### udp |
48 | 42 | //! |
49 | 43 | //! ```Rust |
50 | | -//! #[macro_use] |
51 | | -//! extern crate influx_db_client; |
52 | | -//! |
53 | 44 | //! use influx_db_client::{UdpClient, Point, Value}; |
54 | 45 | //! |
55 | | -//! fn main() { |
56 | | -//! let mut udp = UdpClient::new("127.0.0.1:8089"); |
57 | | -//! udp.add_host("127.0.0.1:8090"); |
| 46 | +//! let mut udp = UdpClient::new("127.0.0.1:8089".parse().unwrap()); |
| 47 | +//! udp.add_host("127.0.0.1:8090".parse().unwrap()); |
58 | 48 | //! |
59 | | -//! let mut point = point!("test"); |
60 | | -//! point.add_field("foo", Value::String(String::from("bar"))); |
| 49 | +//! let mut point = point!("test"); |
| 50 | +//! point.add_field("foo", Value::String(String::from("bar"))); |
61 | 51 | //! |
62 | | -//! let _ = udp.write_point(point).unwrap(); |
63 | | -//! } |
| 52 | +//! udp.write_point(point).unwrap(); |
64 | 53 | //! ``` |
65 | 54 |
|
66 | 55 | #![deny(warnings)] |
|
0 commit comments