Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

### Checklist
- [ ] Formatted code using `cargo fmt --all`
- [ ] Linted code using clippy
- [ ] with reqwest feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings`
- [ ] with surf feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings`
- [ ] Linted code using clippy with reqwest feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings`
- [ ] Updated README.md using `cargo doc2readme -p influxdb --expand-macros`
- [ ] Reviewed the diff. Did you leave any print statements or unnecessary comments?
- [ ] Any unfinished work that warrants a separate issue captured in an issue with a TODO code comment
6 changes: 0 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
run: cargo --config 'resolver.incompatible-rust-versions="fallback"' update
- name: Check Clippy lints (reqwest)
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
- name: Check Clippy lints (surf)
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings

# this checks that the code is formatted with rustfmt
rustfmt:
Expand Down Expand Up @@ -124,10 +122,6 @@ jobs:
toolchain: stable
nightly: false
http-backend:
- curl-client
- h1-client
- h1-client-rustls
- hyper-client
- reqwest-client-rustls
- reqwest-client-native-tls
- reqwest-client-native-tls-vendored
Expand Down
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ use chrono::{DateTime, Utc};
use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};

#[tokio::main]
// or #[async_std::main] if you prefer
async fn main() -> Result<(), Error> {
// Connect to db `test` on `http://localhost:8086`
let client = Client::new("http://localhost:8086", "test");
Expand Down Expand Up @@ -122,55 +121,49 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls-vendored"] }
```

* **[hyper][__link9]** (through surf), use this if you need tokio 0.2 compatibility
```toml
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "hyper-client"] }
```

* **[curl][__link10]**, using [libcurl][__link11]
* **[curl][__link9]**, using [libcurl][__link10]
```toml
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "curl-client"] }
```

* **[async-h1][__link12]** with native TLS (OpenSSL)
* **[async-h1][__link11]** with native TLS (OpenSSL)
```toml
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client"] }
```

* **[async-h1][__link13]** with [rustls][__link14]
* **[async-h1][__link12]** with [rustls][__link13]
```toml
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client-rustls"] }
```

* WebAssembly’s `window.fetch`, via `web-sys` and **[wasm-bindgen][__link15]**
* WebAssembly’s `window.fetch`, via `web-sys` and **[wasm-bindgen][__link14]**
```toml
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "wasm-client"] }
```

## License

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][__link16]
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][__link15]


@ 2020-2024 Gero Gerke, msrd0 and [contributors].

[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG1LaAVLASZMqG5J2qfpyCvbMG_Rohh5BobOmG0DqLv5454SZYWSBgmhpbmZsdXhkYmUwLjcuMg
[__cargo_doc2readme_dependencies_info]: ggGkYW0CYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG4NMwSc-atpuGyQ3O7T4Ur42GzFqIg36Zfn7G7roc8ix9SwDYWSBgmhpbmZsdXhkYmUwLjcuMg
[__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
[__link1]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
[__link10]: https://github.com/alexcrichton/curl-rust
[__link11]: https://curl.se/libcurl/
[__link10]: https://curl.se/libcurl/
[__link11]: https://github.com/http-rs/async-h1
[__link12]: https://github.com/http-rs/async-h1
[__link13]: https://github.com/http-rs/async-h1
[__link14]: https://github.com/ctz/rustls
[__link15]: https://github.com/rustwasm/wasm-bindgen
[__link16]: https://opensource.org/licenses/MIT
[__link13]: https://github.com/ctz/rustls
[__link14]: https://github.com/rustwasm/wasm-bindgen
[__link15]: https://opensource.org/licenses/MIT
[__link2]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CHANGELOG.md
[__link3]: https://github.com/influxdb-rs/influxdb-rust/blob/main/influxdb/Cargo.toml
[__link4]: https://docs.rs/influxdb/0.7.2/influxdb/?search=integrations::serde_integration
[__link5]: https://github.com/hyperium/hyper
[__link6]: https://github.com/ctz/rustls
[__link7]: https://github.com/hyperium/hyper
[__link8]: https://github.com/hyperium/hyper
[__link9]: https://github.com/hyperium/hyper
[__link9]: https://github.com/alexcrichton/curl-rust

15 changes: 4 additions & 11 deletions influxdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ futures-util = "0.3.17"
http = "0.2.4"
influxdb_derive = { version = "0.5.1", optional = true }
lazy-regex = "3.1"
reqwest = { version = "0.11.4", default-features = false, optional = true }
surf = { version = "2.2.0", default-features = false, optional = true }
reqwest = { version = "0.11.4", default-features = false }
serde = { version = "1.0.186", optional = true }
serde_derive = { version = "1.0.186", optional = true }
serde_json = { version = "1.0.48", optional = true }
Expand All @@ -35,16 +34,10 @@ derive = ["dep:influxdb_derive"]
serde = ["dep:serde", "dep:serde_derive", "dep:serde_json"]

# http clients
curl-client = ["surf", "surf/curl-client"]
h1-client = ["surf", "surf/h1-client"]
h1-client-rustls = ["surf", "surf/h1-client-rustls"]
hyper-client = ["surf", "surf/hyper-client"]
reqwest-client-rustls = ["reqwest", "reqwest/rustls-tls-webpki-roots"]
reqwest-client-native-tls = ["reqwest", "reqwest/native-tls-alpn"]
reqwest-client-native-tls-vendored = ["reqwest", "reqwest/native-tls-vendored"]
wasm-client = ["surf", "surf/wasm-client"]
reqwest-client-rustls = ["reqwest/rustls-tls-webpki-roots"]
reqwest-client-native-tls = ["reqwest/native-tls-alpn"]
reqwest-client-native-tls-vendored = ["reqwest/native-tls-vendored"]

[dev-dependencies]
async-std = { version = "1.6.5", features = ["attributes", "tokio02", "tokio1"] }
indoc = "1.0"
tokio = { version = "1.7", features = ["macros", "rt-multi-thread"] }
21 changes: 1 addition & 20 deletions influxdb/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
//! ```

use futures_util::TryFutureExt;
#[cfg(feature = "reqwest")]
use reqwest::{Client as HttpClient, RequestBuilder, Response as HttpResponse};
use std::collections::{BTreeMap, HashMap};
use std::fmt::{self, Debug, Formatter};
use std::sync::Arc;
#[cfg(feature = "surf")]
use surf::{Client as HttpClient, RequestBuilder, Response as HttpResponse};

use crate::query::QueryType;
use crate::Error;
Expand Down Expand Up @@ -168,7 +165,6 @@ impl Client {
const BUILD_HEADER: &str = "X-Influxdb-Build";
const VERSION_HEADER: &str = "X-Influxdb-Version";

#[cfg(feature = "reqwest")]
let (build, version) = {
let hdrs = res.headers();
(
Expand All @@ -178,11 +174,6 @@ impl Client {
)
};

#[cfg(feature = "surf")]
let build = res.header(BUILD_HEADER).map(|value| value.as_str());
#[cfg(feature = "surf")]
let version = res.header(VERSION_HEADER).map(|value| value.as_str());

Ok((build.unwrap().to_owned(), version.unwrap().to_owned()))
}

Expand All @@ -201,7 +192,7 @@ impl Client {
/// use influxdb::InfluxDbWriteable;
/// use std::time::{SystemTime, UNIX_EPOCH};
///
/// # #[async_std::main]
/// # #[tokio::main]
/// # async fn main() -> Result<(), influxdb::Error> {
/// let start = SystemTime::now();
/// let since_the_epoch = start
Expand Down Expand Up @@ -254,11 +245,6 @@ impl Client {
}
};

#[cfg(feature = "surf")]
let request_builder = request_builder.map_err(|err| Error::UrlConstructionError {
error: err.to_string(),
})?;

let res = self
.auth_if_needed(request_builder)
.send()
Expand All @@ -268,12 +254,7 @@ impl Client {
.await?;
check_status(&res)?;

#[cfg(feature = "reqwest")]
let body = res.text();
#[cfg(feature = "surf")]
let mut res = res;
#[cfg(feature = "surf")]
let body = res.body_string();

let s = body.await.map_err(|_| Error::DeserializationError {
error: "response could not be converted to UTF-8".into(),
Expand Down
12 changes: 1 addition & 11 deletions influxdb/src/integrations/serde_integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! weather: WeatherWithoutCityName,
//! }
//!
//! # #[async_std::main]
//! # #[tokio::main]
//! # async fn main() -> Result<(), influxdb::Error> {
//! let client = Client::new("http://localhost:8086", "test");
//! let query = Query::raw_read_query(
Expand Down Expand Up @@ -145,11 +145,6 @@ impl Client {
}
let request_builder = request_builder.query(&parameters);

#[cfg(feature = "surf")]
let request_builder = request_builder.map_err(|err| Error::UrlConstructionError {
error: err.to_string(),
})?;

let res = request_builder
.send()
.await
Expand All @@ -158,12 +153,7 @@ impl Client {
})?;
check_status(&res)?;

#[cfg(feature = "reqwest")]
let body = res.bytes();
#[cfg(feature = "surf")]
let mut res = res;
#[cfg(feature = "surf")]
let body = res.body_bytes();

let body = body.await.map_err(|err| Error::ProtocolError {
error: err.to_string(),
Expand Down
9 changes: 0 additions & 9 deletions influxdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
//! use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};
//!
//! #[tokio::main]
//! // or #[async_std::main] if you prefer
//! async fn main() -> Result<(), Error> {
//! // Connect to db `test` on `http://localhost:8086`
//! let client = Client::new("http://localhost:8086", "test");
Expand Down Expand Up @@ -79,8 +78,6 @@
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "reqwest-client-native-tls")]
//! - **[hyper](https://github.com/hyperium/hyper)** (through reqwest), with vendored native TLS (OpenSSL)
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "reqwest-client-native-tls-vendored")]
//! - **[hyper](https://github.com/hyperium/hyper)** (through surf), use this if you need tokio 0.2 compatibility
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "hyper-client")]
//! - **[curl](https://github.com/alexcrichton/curl-rust)**, using [libcurl](https://curl.se/libcurl/)
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "curl-client")]
//! - **[async-h1](https://github.com/http-rs/async-h1)** with native TLS (OpenSSL)
Expand Down Expand Up @@ -128,12 +125,6 @@ macro_rules! cargo_toml_private {
}
use cargo_toml_private;

#[cfg(all(feature = "reqwest", feature = "surf"))]
compile_error!("You need to choose between reqwest and surf; enabling both is not supported");

#[cfg(not(any(feature = "reqwest", feature = "surf")))]
compile_error!("You need to choose an http client; consider not disabling default features");

mod client;
mod error;
mod query;
Expand Down
4 changes: 2 additions & 2 deletions influxdb/tests/derive_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn test_build_query() {
/// INTEGRATION TEST
///
/// This integration tests that writing data and retrieving the data again is working
#[async_std::test]
#[tokio::test]
#[cfg(not(tarpaulin_include))]
async fn test_derive_simple_write() {
const TEST_NAME: &str = "test_derive_simple_write";
Expand Down Expand Up @@ -82,7 +82,7 @@ async fn test_derive_simple_write() {
/// This integration tests that writing data and retrieving the data again is working
#[cfg(feature = "derive")]
#[cfg(feature = "serde")]
#[async_std::test]
#[tokio::test]
#[cfg(not(tarpaulin_include))]
async fn test_write_and_read_option() {
const TEST_NAME: &str = "test_write_and_read_option";
Expand Down
Loading
Loading