From 46285a29291216a5f879e7fbdb4b7710983be8ed Mon Sep 17 00:00:00 2001 From: driftluo Date: Thu, 12 Mar 2020 12:18:48 +0800 Subject: [PATCH] Update Readme, bump to 0.4.0 --- Cargo.toml | 2 +- README.md | 40 ++++++++++++++++++---------------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 70d0b66..a8bdca5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "influx_db_client" -version = "0.3.6" +version = "0.4.0" authors = ["piaoliu <441594700@qq.com>"] documentation = "https://docs.rs/influx_db_client/" repository = "https://github.com/driftluo/InfluxDBClient-rs" diff --git a/README.md b/README.md index e77ac9b..6caceef 100644 --- a/README.md +++ b/README.md @@ -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)) @@ -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> - let res = client.query("select * from test1", None).unwrap(); - println!("{:?}", res.unwrap()[0].series) + // query, it's type is Option> + 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(); } ```