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 过程宏

Download history 138/week @ 2024-04-01 181/week @ 2024-04-08 112/week @ 2024-04-15 171/week @ 2024-04-22 123/week @ 2024-04-29 171/week @ 2024-05-06 201/week @ 2024-05-13 158/week @ 2024-05-20 239/week @ 2024-05-27 199/week @ 2024-06-03 136/week @ 2024-06-10 122/week @ 2024-06-17 139/week @ 2024-06-24 145/week @ 2024-07-01 94/week @ 2024-07-08 115/week @ 2024-07-15

每月下载量498次

MIT 许可证

13KB
327 代码行

🦀 InfluxDB Rust客户端

tests docs

注意! - 此库仍在开发中,不适合生产使用!

非官方的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