Skip to content

Commit

Permalink
Update Readme, bump to 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Mar 12, 2020
1 parent 9415f39 commit 46285a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "influx_db_client"
version = "0.3.6"
version = "0.4.0"
authors = ["piaoliu <[email protected]>"]
documentation = "https://docs.rs/influx_db_client/"
repository = "https://github.com/driftluo/InfluxDBClient-rs"
Expand Down
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@ This project has been able to run properly, PR is welcome.

```
[dependencies]
influx_db_client = "^0.3.6"
influx_db_client = "^0.4.0"
```

### http

```Rust
#[macro_use]
extern crate influx_db_client;

use influx_db_client::{Client, Point, Points, Value, Precision};
use influx_db_client::{
Client, Point, Points, Value, Precision, point, points
};
use tokio;

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

let mut point = point!("test1");
point
let point = point!("test1")
.add_field("foo", Value::String("bar".to_string()))
.add_field("integer", Value::Integer(11))
.add_field("float", Value::Float(22.3))
Expand All @@ -47,37 +46,34 @@ fn main() {
.add_tag("float", Value::Float(12.6))
.add_field("fd", Value::String("'3'".to_string()))
.add_field("quto", Value::String("\\\"fda".to_string()))
.add_field("quto1", Value::String("\"fda".to_string()))
.to_owned();
.add_field("quto1", Value::String("\"fda".to_string()));

let points = points!(point1, point);

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

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

### udp

```Rust
#[macro_use]
extern crate influx_db_client;

use influx_db_client::{UdpClient, Point, Value};
use influx_db_client::{UdpClient, Point, Value, point};

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

let mut point = point!("test");
point.add_field("foo", Value::String(String::from("bar")));
let point = point!("test").add_field("foo", Value::String(String::from("bar")));

let _ = udp.write_point(point).unwrap();
udp.write_point(point).unwrap();
}
```

Expand Down

0 comments on commit 46285a2

Please sign in to comment.