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

macro influxdb-derives

InfluxDBv2 Rust client - struct serialization for line protocol

2 releases

0.1.1 Mar 2, 2021
0.1.0 Feb 28, 2021

#51 in #influx-db

Download history 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 34/week @ 2024-07-22

376 downloads per month
Used in influxdb-client

MIT license

8KB
138 lines

🦀 InfluxDB Rust Client

tests docs

NB! - This library is still in development and is not ready for production!

An unofficial client-library for InfluxDB v2.

⬇️ Installation

influxdb-client = "0.1.4"

❤️‍🔥 Usage

Insert by building a Point

use influxdb_client::{Client, Point, Precision, TimestampOptions};

let client = Client::new("http://localhost: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;

Insert using a struct


use influxdb_client::{Client, Precision, PointSerialize, TimestampOptions, Timestamp};
use influxdb_client::derives::PointSerialize;

let client = Client::new("http://localhost: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

This todolist is still in progress and will be expanded in the future.

  • Implement insertion into InfluxDB from client
  • Implement procedural macro for implementing PointSerialize
  • Implement querying
  • Implement other important things

Dependencies

~1.5MB
~37K SLoC