#influx-db #struct #client #protocols #serialization #line #point

influxdb-derives

InfluxDBv2 Rust客户端 - 行协议的struct序列化

2个版本

0.1.1 2021年3月2日
0.1.0 2021年2月28日

#52 in #influx-db

Download history 174/week @ 2024-04-01 183/week @ 2024-04-08 115/week @ 2024-04-15 173/week @ 2024-04-22 127/week @ 2024-04-29 176/week @ 2024-05-06 206/week @ 2024-05-13 162/week @ 2024-05-20 242/week @ 2024-05-27 203/week @ 2024-06-03 137/week @ 2024-06-10 125/week @ 2024-06-17 142/week @ 2024-06-24 116/week @ 2024-07-01 97/week @ 2024-07-08 120/week @ 2024-07-15

每月480次下载
用于 influxdb-client

MIT 许可证

8KB
138

🦀 InfluxDB Rust客户端

tests docs

NB! - 此库仍在开发中,尚未准备用于生产!

为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;

使用struct进行插入


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的过程宏
  • 实现查询
  • 实现其他重要事项

依赖项

~1.5MB
~36K SLoC