influxdb/influxdb_iox_client
dependabot[bot] 5a79b3a68b
chore(deps): Bump arrow-flight from 9.0.2 to 9.1.0 (#3829)
Bumps [arrow-flight](https://github.com/apache/arrow-rs) from 9.0.2 to 9.1.0.
- [Release notes](https://github.com/apache/arrow-rs/releases)
- [Changelog](https://github.com/apache/arrow-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/apache/arrow-rs/compare/9.0.2...9.1.0)

---
updated-dependencies:
- dependency-name: arrow-flight
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-02-23 11:03:22 +00:00
..
src feat: CLI and gRPC APIs for shutting down and restarting databases (#3720) 2022-02-11 10:14:43 +00:00
Cargo.toml chore(deps): Bump arrow-flight from 9.0.2 to 9.1.0 (#3829) 2022-02-23 11:03:22 +00:00
README.md chore: remove unused code 2021-04-08 10:02:28 -04:00

README.md

InfluxDB IOx Client

This is the official Rust client library for connecting to InfluxDB IOx.

Using the HTTP API

If you only want to use the HTTP API, create an influxdb_iox_client::Client. Here is an example of creating an instance that connects to an IOx server running at http://127.0.0.1:8080 and creating a database named telemetry:

#[tokio::main]
fn main() {
    use data_types::database_rules::DatabaseRules;
    use influxdb_iox_client::ClientBuilder;

    let client = ClientBuilder::default()
        .build("http://127.0.0.1:8080")
        .expect("client should be valid");

    client
        .create_database("telemetry", &DatabaseRules::default())
        .await
        .expect("failed to create database");
}

Using the Arrow Flight API

IOx supports an Arrow Flight gRPC API. To use it, enable the flight feature, which is off by default:

[dependencies]
influxdb_iox_client = { version = "[..]", features = ["flight"] }

Then you can create an influxdb_iox_client::FlightClient by using the FlightClientBuilder. Here is an example of creating an instance that connects to an IOx server with its gRPC services available at http://localhost:8082 and using it to perform a query:

#[tokio::main]
fn main() {
    use data_types::database_rules::DatabaseRules;
    use influxdb_iox_client::FlightClientBuilder;

    let client = FlightClientBuilder::default()
        .build("http://127.0.0.1:8082")
        .expect("client should be valid");

    let mut query_results = client
        .perform_query(scenario.database_name(), sql_query)
        .await;

    let mut batches = vec![];

    while let Some(data) = query_results.next().await {
        batches.push(data);
    }
}