Skip to content

Commit ad0d84a

Browse files
Empty2k12msrd0
andauthored
[#147] Remove surf support (#168)
* [#147] Remove surf support Fixes #147 * remove some more stuff * make reqwest not optional anymore * possibly fix build error * remove reqwest feature gates * tokioize some more * cargo fmt * updates based on PR feedback --------- Co-authored-by: Dominic <[email protected]>
1 parent 9174a4f commit ad0d84a

File tree

10 files changed

+29
-138
lines changed

10 files changed

+29
-138
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
### Checklist
66
- [ ] Formatted code using `cargo fmt --all`
7-
- [ ] Linted code using clippy
8-
- [ ] with reqwest feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features chrono,time,serde,derive,reqwest-client-rustls -- -D warnings`
9-
- [ ] with surf feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features chrono,time,serde,derive,hyper-client -- -D warnings`
7+
- [ ] Linted code using clippy with reqwest feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features chrono,time,serde,derive,reqwest-client-rustls -- -D warnings`
108
- [ ] Updated README.md using `cargo doc2readme -p influxdb --expand-macros`
119
- [ ] Reviewed the diff. Did you leave any print statements or unnecessary comments?
1210
- [ ] Any unfinished work that warrants a separate issue captured in an issue with a TODO code comment

.github/workflows/rust.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ jobs:
3131
run: cargo --config 'resolver.incompatible-rust-versions="fallback"' update
3232
- name: Check Clippy lints (reqwest)
3333
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features chrono,time,serde,derive,reqwest-client-rustls -- -D warnings
34-
- name: Check Clippy lints (surf)
35-
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features chrono,time,serde,derive,hyper-client -- -D warnings
3634

3735
# this checks that the code is formatted with rustfmt
3836
rustfmt:

README.md

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ use chrono::{DateTime, Utc};
6060
use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};
6161

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

125-
* **[hyper][__link9]** (through surf), use this if you need tokio 0.2 compatibility
126-
```toml
127-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "hyper-client"] }
128-
```
129-
130-
* **[curl][__link10]**, using [libcurl][__link11]
131-
```toml
132-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "curl-client"] }
133-
```
134-
135-
* **[async-h1][__link12]** with native TLS (OpenSSL)
136-
```toml
137-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client"] }
138-
```
139-
140-
* **[async-h1][__link13]** with [rustls][__link14]
141-
```toml
142-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client-rustls"] }
143-
```
144-
145-
* WebAssembly’s `window.fetch`, via `web-sys` and **[wasm-bindgen][__link15]**
146-
```toml
147-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "wasm-client"] }
148-
```
149-
150124
## License
151125

152-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][__link16]
126+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][__link9]
153127

154128

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

157131
[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
158-
[__cargo_doc2readme_dependencies_info]: ggGkYW0CYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG1LaAVLASZMqG5J2qfpyCvbMG_Rohh5BobOmG0DqLv5454SZYWSBgmhpbmZsdXhkYmUwLjcuMg
132+
[__cargo_doc2readme_dependencies_info]: ggGkYW0CYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG8LHWNBBuXgSGz-2Lrx4E_kTG0bJiXb6A8zNG9GhXhvU8L0xYWSBgmhpbmZsdXhkYmUwLjcuMg
159133
[__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
160134
[__link1]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
161-
[__link10]: https://github.com/alexcrichton/curl-rust
162-
[__link11]: https://curl.se/libcurl/
163-
[__link12]: https://github.com/http-rs/async-h1
164-
[__link13]: https://github.com/http-rs/async-h1
165-
[__link14]: https://github.com/ctz/rustls
166-
[__link15]: https://github.com/rustwasm/wasm-bindgen
167-
[__link16]: https://opensource.org/licenses/MIT
168135
[__link2]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CHANGELOG.md
169136
[__link3]: https://github.com/influxdb-rs/influxdb-rust/blob/main/influxdb/Cargo.toml
170137
[__link4]: https://docs.rs/influxdb/0.7.2/influxdb/?search=integrations::serde_integration
171138
[__link5]: https://github.com/hyperium/hyper
172139
[__link6]: https://github.com/ctz/rustls
173140
[__link7]: https://github.com/hyperium/hyper
174141
[__link8]: https://github.com/hyperium/hyper
175-
[__link9]: https://github.com/hyperium/hyper
142+
[__link9]: https://opensource.org/licenses/MIT
176143

influxdb/Cargo.toml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ futures-util = "0.3.17"
2222
http = "0.2.4"
2323
influxdb_derive = { version = "0.5.1", optional = true }
2424
lazy-regex = "3.1"
25-
reqwest = { version = "0.11.4", default-features = false, optional = true }
25+
reqwest = { version = "0.11.4", default-features = false }
2626
serde = { version = "1.0.186", optional = true }
2727
serde_derive = { version = "1.0.186", optional = true }
2828
serde_json = { version = "1.0.48", optional = true }
@@ -36,20 +36,14 @@ derive = ["dep:influxdb_derive"]
3636
serde = ["dep:serde", "dep:serde_derive", "dep:serde_json"]
3737

3838
# http clients
39-
curl-client = ["surf", "surf/curl-client"]
40-
h1-client = ["surf", "surf/h1-client"]
41-
h1-client-rustls = ["surf", "surf/h1-client-rustls"]
42-
hyper-client = ["surf", "surf/hyper-client"]
43-
reqwest-client-rustls = ["reqwest", "reqwest/rustls-tls-webpki-roots"]
44-
reqwest-client-native-tls = ["reqwest", "reqwest/native-tls-alpn"]
45-
reqwest-client-native-tls-vendored = ["reqwest", "reqwest/native-tls-vendored"]
46-
wasm-client = ["surf", "surf/wasm-client"]
39+
reqwest-client-rustls = ["reqwest/rustls-tls-webpki-roots"]
40+
reqwest-client-native-tls = ["reqwest/native-tls-alpn"]
41+
reqwest-client-native-tls-vendored = ["reqwest/native-tls-vendored"]
4742

4843
# etc
4944
time = ["dep:time"]
5045
chrono = ["dep:chrono"]
5146

5247
[dev-dependencies]
53-
async-std = { version = "1.6.5", features = ["attributes", "tokio02", "tokio1"] }
5448
indoc = "1.0"
5549
tokio = { version = "1.7", features = ["macros", "rt-multi-thread"] }

influxdb/src/client/mod.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
//! ```
1717
1818
use futures_util::TryFutureExt;
19-
#[cfg(feature = "reqwest")]
2019
use reqwest::{Client as HttpClient, RequestBuilder, Response as HttpResponse};
2120
use std::collections::{BTreeMap, HashMap};
2221
use std::fmt::{self, Debug, Formatter};
2322
use std::sync::Arc;
24-
#[cfg(feature = "surf")]
25-
use surf::{Client as HttpClient, RequestBuilder, Response as HttpResponse};
2623

2724
use crate::query::QueryType;
2825
use crate::Error;
@@ -168,7 +165,6 @@ impl Client {
168165
const BUILD_HEADER: &str = "X-Influxdb-Build";
169166
const VERSION_HEADER: &str = "X-Influxdb-Version";
170167

171-
#[cfg(feature = "reqwest")]
172168
let (build, version) = {
173169
let hdrs = res.headers();
174170
(
@@ -178,11 +174,6 @@ impl Client {
178174
)
179175
};
180176

181-
#[cfg(feature = "surf")]
182-
let build = res.header(BUILD_HEADER).map(|value| value.as_str());
183-
#[cfg(feature = "surf")]
184-
let version = res.header(VERSION_HEADER).map(|value| value.as_str());
185-
186177
Ok((build.unwrap().to_owned(), version.unwrap().to_owned()))
187178
}
188179

@@ -201,7 +192,7 @@ impl Client {
201192
/// use influxdb::InfluxDbWriteable;
202193
/// use std::time::{SystemTime, UNIX_EPOCH};
203194
///
204-
/// # #[async_std::main]
195+
/// # #[tokio::main]
205196
/// # async fn main() -> Result<(), influxdb::Error> {
206197
/// let start = SystemTime::now();
207198
/// let since_the_epoch = start
@@ -254,11 +245,6 @@ impl Client {
254245
}
255246
};
256247

257-
#[cfg(feature = "surf")]
258-
let request_builder = request_builder.map_err(|err| Error::UrlConstructionError {
259-
error: err.to_string(),
260-
})?;
261-
262248
let res = self
263249
.auth_if_needed(request_builder)
264250
.send()
@@ -268,12 +254,7 @@ impl Client {
268254
.await?;
269255
check_status(&res)?;
270256

271-
#[cfg(feature = "reqwest")]
272257
let body = res.text();
273-
#[cfg(feature = "surf")]
274-
let mut res = res;
275-
#[cfg(feature = "surf")]
276-
let body = res.body_string();
277258

278259
let s = body.await.map_err(|_| Error::DeserializationError {
279260
error: "response could not be converted to UTF-8".into(),

influxdb/src/integrations/serde_integration/mod.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! weather: WeatherWithoutCityName,
2222
//! }
2323
//!
24-
//! # #[async_std::main]
24+
//! # #[tokio::main]
2525
//! # async fn main() -> Result<(), influxdb::Error> {
2626
//! let client = Client::new("http://localhost:8086", "test");
2727
//! let query = Query::raw_read_query(
@@ -145,11 +145,6 @@ impl Client {
145145
}
146146
let request_builder = request_builder.query(&parameters);
147147

148-
#[cfg(feature = "surf")]
149-
let request_builder = request_builder.map_err(|err| Error::UrlConstructionError {
150-
error: err.to_string(),
151-
})?;
152-
153148
let res = request_builder
154149
.send()
155150
.await
@@ -158,12 +153,7 @@ impl Client {
158153
})?;
159154
check_status(&res)?;
160155

161-
#[cfg(feature = "reqwest")]
162156
let body = res.bytes();
163-
#[cfg(feature = "surf")]
164-
let mut res = res;
165-
#[cfg(feature = "surf")]
166-
let body = res.body_bytes();
167157

168158
let body = body.await.map_err(|err| Error::ProtocolError {
169159
error: err.to_string(),

influxdb/src/lib.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
//! use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};
2727
//!
2828
//! #[tokio::main]
29-
//! // or #[async_std::main] if you prefer
3029
//! async fn main() -> Result<(), Error> {
3130
//! // Connect to db `test` on `http://localhost:8086`
3231
//! let client = Client::new("http://localhost:8086", "test");
@@ -79,16 +78,6 @@
7978
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "reqwest-client-native-tls")]
8079
//! - **[hyper](https://github.com/hyperium/hyper)** (through reqwest), with vendored native TLS (OpenSSL)
8180
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "reqwest-client-native-tls-vendored")]
82-
//! - **[hyper](https://github.com/hyperium/hyper)** (through surf), use this if you need tokio 0.2 compatibility
83-
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "hyper-client")]
84-
//! - **[curl](https://github.com/alexcrichton/curl-rust)**, using [libcurl](https://curl.se/libcurl/)
85-
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "curl-client")]
86-
//! - **[async-h1](https://github.com/http-rs/async-h1)** with native TLS (OpenSSL)
87-
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "h1-client")]
88-
//! - **[async-h1](https://github.com/http-rs/async-h1)** with [rustls](https://github.com/ctz/rustls)
89-
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "h1-client-rustls")]
90-
//! - WebAssembly's `window.fetch`, via `web-sys` and **[wasm-bindgen](https://github.com/rustwasm/wasm-bindgen)**
91-
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "wasm-client")]
9281
//!
9382
//! # License
9483
//!
@@ -128,12 +117,6 @@ macro_rules! cargo_toml_private {
128117
}
129118
use cargo_toml_private;
130119

131-
#[cfg(all(feature = "reqwest", feature = "surf"))]
132-
compile_error!("You need to choose between reqwest and surf; enabling both is not supported");
133-
134-
#[cfg(not(any(feature = "reqwest", feature = "surf")))]
135-
compile_error!("You need to choose an http client; consider not disabling default features");
136-
137120
mod client;
138121
mod error;
139122
mod query;

influxdb/tests/derive_integration_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn test_build_query() {
5151
/// INTEGRATION TEST
5252
///
5353
/// This integration tests that writing data and retrieving the data again is working
54-
#[async_std::test]
54+
#[tokio::test]
5555
#[cfg(not(tarpaulin_include))]
5656
async fn test_derive_simple_write() {
5757
const TEST_NAME: &str = "test_derive_simple_write";
@@ -82,7 +82,7 @@ async fn test_derive_simple_write() {
8282
/// This integration tests that writing data and retrieving the data again is working
8383
#[cfg(feature = "derive")]
8484
#[cfg(feature = "serde")]
85-
#[async_std::test]
85+
#[tokio::test]
8686
#[cfg(not(tarpaulin_include))]
8787
async fn test_write_and_read_option() {
8888
const TEST_NAME: &str = "test_write_and_read_option";

0 commit comments

Comments
 (0)