influxdb_stream/lib.rs
1//! # influxdb-stream
2//!
3//! Async streaming client for InfluxDB 2.x that lets you query millions of rows
4//! without running out of memory.
5//!
6//! ## Why?
7//!
8//! Existing Rust InfluxDB clients load entire query results into memory:
9//!
10//! ```ignore
11//! // This will OOM with millions of rows!
12//! let results: Vec<MyData> = client.query(query).await?;
13//! ```
14//!
15//! `influxdb-stream` streams results one record at a time:
16//!
17//! ```ignore
18//! // Process millions of rows with constant memory usage
19//! let mut stream = client.query_stream(query).await?;
20//! while let Some(record) = stream.next().await {
21//! process(record?);
22//! }
23//! ```
24//!
25//! ## Quick Start
26//!
27//! ```ignore
28//! use influxdb_stream::Client;
29//! use futures::StreamExt;
30//!
31//! #[tokio::main]
32//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
33//! let client = Client::new("http://localhost:8086", "my-org", "my-token");
34//!
35//! let mut stream = client.query_stream(r#"
36//! from(bucket: "sensors")
37//! |> range(start: -30d)
38//! |> filter(fn: (r) => r._measurement == "temperature")
39//! "#).await?;
40//!
41//! while let Some(record) = stream.next().await {
42//! let record = record?;
43//! println!(
44//! "{}: {} = {:?}",
45//! record.measurement().unwrap_or_default(),
46//! record.field().unwrap_or_default(),
47//! record.value()
48//! );
49//! }
50//!
51//! Ok(())
52//! }
53//! ```
54//!
55//! ## Features
56//!
57//! - **Memory efficient**: Streams results without loading everything into memory
58//! - **Async native**: Built on tokio and futures
59//! - **All data types**: Supports all InfluxDB data types (string, double, bool,
60//! long, unsignedLong, duration, base64Binary, dateTime:RFC3339)
61//! - **Error handling**: All errors are returned as Results, no panics
62//! - **Zero copy parsing**: Parses InfluxDB's annotated CSV format on the fly
63
64pub mod client;
65pub mod error;
66pub mod parser;
67pub mod types;
68pub mod value;
69
70// Re-export main types at crate root
71pub use client::Client;
72pub use error::{Error, Result};
73pub use types::{DataType, FluxColumn, FluxRecord, FluxTableMetadata};
74pub use value::Value;
75
76// Re-export parser for advanced use cases
77pub use parser::AnnotatedCsvParser;