Skip to content

Rust influx is Rust based influx client implementation that have been inspired from influx other language implementation, developed with ๐Ÿ’–

License

Notifications You must be signed in to change notification settings

workfoxes/rinflux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


rust-influxdb

Unofficial InfluxDB Driver for Rust

Build Status Coverage Report Documentation Status Build with Rust Minimum Rust Version

This library is a work in progress. This means a feature you might need is not implemented yet or could be handled better.

Pull requests are always welcome. See Contributing and Code of Conduct. For a list of past changes, see CHANGELOG.md.

Currently, Supported Features

  • Reading and Writing to InfluxDB
  • Optional Serde Support for Deserialization
  • Running multiple queries in one request (e.g. SELECT * FROM weather_berlin; SELECT * FROM weather_london)
  • Authenticated and Unauthenticated Connections
  • async/await support
  • #[derive(InfluxDbWriteable)] Derive Macro for Writing / Reading into Structs
  • GROUP BY support
  • Tokio and async-std support (see example below) or available backends
  • Swappable HTTP backends (see below)

Quickstart

Add the following to your Cargo.toml

rinflux = { version = "0.1.0", git = "https://github.com/workfoxes/rinflux.git" }

For an example with using Serde deserialization, please refer to serde_integration

use rinflux::{Client, Query, Timestamp, ReadQuery};
use rinflux::InfluxDbWriteable;
use chrono::{DateTime, Utc};

#[tokio::main]
// or #[async_std::main] if you prefer
async fn main() {
    // Connect to db `test` on `http://localhost:8086`
    let client = Client::new("http://localhost:8086", "test");

    #[derive(InfluxDbWriteable)]
    struct WeatherReading {
        time: DateTime<Utc>,
        humidity: i32,
        #[influxdb(tag)] wind_direction: String,
    }

    // Let's write some data into a measurement called `weather`
    let weather_reading = WeatherReading {
        time: Timestamp::Hours(1).into(),
        humidity: 30,
        wind_direction: String::from("north"),
    };

    let write_result = client
        .query(weather_reading.into_query("weather"))
        .await;
    assert!(write_result.is_ok(), "Write result was not okay");

    // Let's see if the data we wrote is there
    let read_query = ReadQuery::new("SELECT * FROM weather");

    let read_result = client.query(read_query).await;
    assert!(read_result.is_ok(), "Read result was not ok");
    println!("{}", read_result.unwrap());
}

License

License: MIT

@ 2022 Workfoxes and contributors.

About

Rust influx is Rust based influx client implementation that have been inspired from influx other language implementation, developed with ๐Ÿ’–

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published