5个版本
0.1.4 | 2021年3月4日 |
---|---|
0.1.3 | 2021年3月2日 |
0.1.2 | 2021年3月2日 |
0.1.1 | 2021年2月28日 |
0.1.0 | 2021年2月28日 |
#523 in 过程宏
每月下载量498次
13KB
327 代码行
🦀 InfluxDB Rust客户端
注意! - 此库仍在开发中,不适合生产使用!
非官方的InfluxDB v2客户端库。
⬇️ 安装
influxdb-client = "0.1.4"
❤️🔥 使用
通过构建一个Point来插入
use influxdb_client::{Client, Point, Precision, TimestampOptions};
let client = Client::new("https://127.0.0.1:8086", "token")
.with_org_id("168f31904923e853")
.with_bucket("tradely")
.with_precision(Precision::MS);
let point = Point::new("test")
.tag("ticker", "GME")
.field("price", 420.69)
.timestamp(1614956250000);
let points = vec![point];
// Insert with the timestamp from the point (1614956250000)
let result = client.insert_points(&points, TimestampOptions::FromPoint).await;
使用结构体插入
use influxdb_client::{Client, Precision, PointSerialize, TimestampOptions, Timestamp};
use influxdb_client::derives::PointSerialize;
let client = Client::new("https://127.0.0.1:8086", "token")
.with_org_id("168f31904923e853")
.with_bucket("tradely")
.with_precision(Precision::MS);
#[derive(PointSerialize)]
#[point(measurement = "test")]
struct Ticker {
#[point(tag)]
ticker: String,
#[point(field = "tickerPrice")]
price: f64,
#[point(timestamp)]
timestamp: Timestamp,
}
let point = Ticker {
ticker: String::from("GME"),
price: 420.69,
timestamp: Timestamp::from(1614956250000)
};
let points = vec![point];
// Insert without timestamp - InfluxDB will automatically set the timestamp
let result = client.insert_points(&points, TimestampOptions::None).await;
🪧 TODO
此待办事项列表仍在进行中,并将在未来扩展。
- 从客户端实现向InfluxDB的插入
- 实现实现PointSerialize的过程宏
- 实现查询
- 实现其他重要的事情
依赖项
~4–16MB
~244K SLoC