#influx-db #struct #client #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

#54 in #influx-db

Download history 130/week @ 2023-12-01 155/week @ 2023-12-08 84/week @ 2023-12-15 35/week @ 2023-12-22 43/week @ 2023-12-29 71/week @ 2024-01-05 69/week @ 2024-01-12 66/week @ 2024-01-19 49/week @ 2024-01-26 107/week @ 2024-02-02 84/week @ 2024-02-09 104/week @ 2024-02-16 145/week @ 2024-02-23 149/week @ 2024-03-01 122/week @ 2024-03-08 130/week @ 2024-03-15

562 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
~35K SLoC