Skip to content

Commit 46285a2

Browse files
committed
Update Readme, bump to 0.4.0
1 parent 9415f39 commit 46285a2

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "influx_db_client"
3-
version = "0.3.6"
3+
version = "0.4.0"
44
authors = ["piaoliu <[email protected]>"]
55
documentation = "https://docs.rs/influx_db_client/"
66
repository = "https://github.com/driftluo/InfluxDBClient-rs"

README.md

+18-22
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,22 @@ This project has been able to run properly, PR is welcome.
1919

2020
```
2121
[dependencies]
22-
influx_db_client = "^0.3.6"
22+
influx_db_client = "^0.4.0"
2323
```
2424

2525
### http
2626

2727
```Rust
28-
#[macro_use]
29-
extern crate influx_db_client;
30-
31-
use influx_db_client::{Client, Point, Points, Value, Precision};
28+
use influx_db_client::{
29+
Client, Point, Points, Value, Precision, point, points
30+
};
31+
use tokio;
3232

3333
fn main() {
3434
// default with "http://127.0.0.1:8086", db with "test"
3535
let client = Client::default().set_authentication("root", "root");
3636

37-
let mut point = point!("test1");
38-
point
37+
let point = point!("test1")
3938
.add_field("foo", Value::String("bar".to_string()))
4039
.add_field("integer", Value::Integer(11))
4140
.add_field("float", Value::Float(22.3))
@@ -47,37 +46,34 @@ fn main() {
4746
.add_tag("float", Value::Float(12.6))
4847
.add_field("fd", Value::String("'3'".to_string()))
4948
.add_field("quto", Value::String("\\\"fda".to_string()))
50-
.add_field("quto1", Value::String("\"fda".to_string()))
51-
.to_owned();
49+
.add_field("quto1", Value::String("\"fda".to_string()));
5250

5351
let points = points!(point1, point);
5452

55-
// if Precision is None, the default is second
56-
// Multiple write
57-
let _ = client.write_points(points, Some(Precision::Seconds), None).unwrap();
53+
tokio::runtime::Runtime::new().unwrap().block_on(async move {
54+
// if Precision is None, the default is second
55+
// Multiple write
56+
client.write_points(points, Some(Precision::Seconds), None).await.unwrap();
5857

59-
// query, it's type is Option<Vec<Node>>
60-
let res = client.query("select * from test1", None).unwrap();
61-
println!("{:?}", res.unwrap()[0].series)
58+
// query, it's type is Option<Vec<Node>>
59+
let res = client.query("select * from test1", None).await.unwrap();
60+
println!("{:?}", res.unwrap()[0].series)
61+
});
6262
}
6363
```
6464

6565
### udp
6666

6767
```Rust
68-
#[macro_use]
69-
extern crate influx_db_client;
70-
71-
use influx_db_client::{UdpClient, Point, Value};
68+
use influx_db_client::{UdpClient, Point, Value, point};
7269

7370
fn main() {
7471
let mut udp = UdpClient::new("127.0.0.1:8089");
7572
udp.add_host("127.0.0.1:8090");
7673

77-
let mut point = point!("test");
78-
point.add_field("foo", Value::String(String::from("bar")));
74+
let point = point!("test").add_field("foo", Value::String(String::from("bar")));
7975

80-
let _ = udp.write_point(point).unwrap();
76+
udp.write_point(point).unwrap();
8177
}
8278
```
8379

0 commit comments

Comments
 (0)