Crate influxc

Source
Expand description

§InfluxDB Client Library

§About this crate

§What this crate provides

  • Support for InfluxDB 2.x.
  • Backlog storage of Record’s on failure to commit due to connectivity or configuration issues.
  • Build-in compression of requests.

§What it does not provide

  • Support for InfluxDB 1.x

§What is on the roadmap

  • Support for async/await as a feature. #3
  • Reduction of dependencies by switching the underlying reqwest library with hyper. #4
  • Support for sending, processing responses to queries. #5
  • Support for mapping native types to query response data like sqlx. #6

§Basic Usage

use influxc::Client;
use influxc::FileBacklog;

use influxc::Record;
use influxc::Precision;
use influxc::Credentials;
use influxc::InfluxError;

use std::time::Duration;
use std::thread::sleep;

fn main() -> Result<(), InfluxError>
{
    let creds   = Credentials::from_basic("testuser", "testpasswd");
    let backlog = FileBacklog::new("./ignore/backlog")?;

    let mut client = Client::build("http://127.0.0.1:8086".into(), creds)
        .backlog(backlog)
        .finish()?;

    let mut rec = Record::new("org", "bucket")
        .precision(Precision::Milliseconds);

    loop
    {
        rec.measurement("sensor1")
            .tag("floor", "second")
            .tag("exposure", "west")
            .field("temp", 123)
            .field("brightness", 500);

        rec.measurement("sensor2")
            .tag("floor", "second")
            .tag("exposure", "east")
            .field("temp", 321)
            .field("brightness", 999);

        if let Err(e) = client.write(&rec) {
            eprintln!("{}", e);
        }

        sleep(Duration::from_secs(1));
    }
}

Structs§

Client
The basic unit of interactino with the InfluxDB API.
ClientBuilder
Builder to piece by piece assemble a Client instance
FileBacklog
Backlog for the Client to persist Record`s that could not be submitted to the InfluxDB due to conectivity or configuration errors.
Measurement
The smallest unit of recording. Multiple of these Measurements are fit in a Record, which in turn is submitted to InfluxDB.
NoopBacklog
Backlog that does nothing
Record
Coarse unit of recording. It keeps track of the organization, bucket and precision which are inherent to the concept of “schema” in SQL lingo. It gets filled with measurements that provide the “table name” (measurement) as well as “indexed columns” (tags) and values.

Enums§

Credentials
Credentials used to authenticate at the InfluxDB server
InfluxError
Chaining Support
Precision
The time resolution the bucket is to keep its measurements
Value
Type primitives as supported by InfluxDB and their conversions from/to Rust primitives

Traits§

Backlog
API definition that any backlog service needs to abide by so the Client can use it.