Skip to content

Commit aa69c36

Browse files
committed
[#147] Remove surf support
Fixes #147
1 parent b3598e8 commit aa69c36

File tree

7 files changed

+69
-104
lines changed

7 files changed

+69
-104
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 serde,derive,reqwest-client-rustls -- -D warnings`
9-
- [ ] with surf feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features 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 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 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 serde,derive,hyper-client -- -D warnings
3634

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

README.md

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,33 @@
3232

3333
Pull requests are always welcome. See [Contributing][__link0] and [Code of Conduct][__link1]. For a list of past changes, see [CHANGELOG.md][__link2].
3434

35+
3536
### Currently Supported Features
3637

37-
* Reading and writing to InfluxDB
38-
* Optional Serde support for deserialization
39-
* Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
40-
* Writing single or multiple measurements in one request (e.g. `WriteQuery` or `Vec<WriteQuery>` argument)
41-
* Authenticated and unauthenticated connections
42-
* `async`/`await` support
43-
* `#[derive(InfluxDbWriteable)]` derive macro for writing / reading into structs
44-
* `GROUP BY` support
45-
* Tokio and async-std support (see example below) or [available backends][__link3]
46-
* Swappable HTTP backends ([see below](#Choice-of-HTTP-backend))
38+
- Reading and writing to InfluxDB
39+
- Optional Serde support for deserialization
40+
- Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
41+
- Writing single or multiple measurements in one request (e.g. `WriteQuery` or `Vec<WriteQuery>` argument)
42+
- Authenticated and unauthenticated connections
43+
- `async`/`await` support
44+
- `#[derive(InfluxDbWriteable)]` derive macro for writing / reading into structs
45+
- `GROUP BY` support
46+
- Tokio and async-std support (see example below) or [available backends][__link3]
47+
- Swappable HTTP backends ([see below](#Choice-of-HTTP-backend))
48+
4749

4850
## Quickstart
4951

5052
Add the following to your `Cargo.toml`
5153

54+
5255
```toml
5356
influxdb = { version = "0.7.2", features = ["derive"] }
5457
```
5558

5659
For an example with using Serde deserialization, please refer to [serde_integration][__link4]
5760

61+
5862
```rust
5963
use chrono::{DateTime, Utc};
6064
use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};
@@ -100,70 +104,75 @@ async fn main() -> Result<(), Error> {
100104
}
101105
```
102106

103-
For further examples, check out the integration tests in `tests/integration_tests.rs`
104-
in the repository.
107+
For further examples, check out the integration tests in `tests/integration_tests.rs` in the repository.
108+
105109

106110
## Choice of HTTP backend
107111

108112
To communicate with InfluxDB, you can choose the HTTP backend to be used configuring the appropriate feature. We recommend sticking with the default reqwest-based client, unless you really need async-std compatibility.
109113

110-
* **[hyper][__link5]** (through reqwest, used by default), with [rustls][__link6]
111-
```toml
112-
influxdb = { version = "0.7.2", features = ["derive"] }
113-
```
114-
115-
* **[hyper][__link7]** (through reqwest), with native TLS (OpenSSL)
116-
```toml
117-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls"] }
118-
```
119-
120-
* **[hyper][__link8]** (through reqwest), with vendored native TLS (OpenSSL)
121-
```toml
122-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls-vendored"] }
123-
```
124-
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-
```
114+
- **[hyper][__link5]** (through reqwest, used by default), with [rustls][__link6]
115+
```toml
116+
influxdb = { version = "0.7.2", features = ["derive"] }
117+
```
118+
119+
120+
- **[hyper][__link7]** (through reqwest), with native TLS (OpenSSL)
121+
```toml
122+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls"] }
123+
```
124+
125+
126+
- **[hyper][__link8]** (through reqwest), with vendored native TLS (OpenSSL)
127+
```toml
128+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls-vendored"] }
129+
```
130+
131+
132+
- **[curl][__link9]**, using [libcurl][__link10]
133+
```toml
134+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "curl-client"] }
135+
```
136+
137+
138+
- **[async-h1][__link11]** with native TLS (OpenSSL)
139+
```toml
140+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client"] }
141+
```
142+
143+
144+
- **[async-h1][__link12]** with [rustls][__link13]
145+
```toml
146+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client-rustls"] }
147+
```
148+
149+
150+
- WebAssembly’s `window.fetch`, via `web-sys` and **[wasm-bindgen][__link14]**
151+
```toml
152+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "wasm-client"] }
153+
```
154+
155+
156+
149157

150158
## License
151159

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

154163

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

157166
[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
158-
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG1LaAVLASZMqG5J2qfpyCvbMG_Rohh5BobOmG0DqLv5454SZYWSBgmhpbmZsdXhkYmUwLjcuMg
167+
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG9BSlXCisRNxGyudsuAyPU_iG753wscIDhrEG2I5swlqlF_MYWSBgmhpbmZsdXhkYmUwLjcuMg
159168
[__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
160169
[__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/
170+
[__link10]: https://curl.se/libcurl/
171+
[__link11]: https://github.com/http-rs/async-h1
163172
[__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
173+
[__link13]: https://github.com/ctz/rustls
174+
[__link14]: https://github.com/rustwasm/wasm-bindgen
175+
[__link15]: https://img.shields.io/badge/License-MIT-yellow.svg
167176
[__link16]: https://opensource.org/licenses/MIT
168177
[__link2]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CHANGELOG.md
169178
[__link3]: https://github.com/influxdb-rs/influxdb-rust/blob/main/influxdb/Cargo.toml
@@ -172,5 +181,5 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
172181
[__link6]: https://github.com/ctz/rustls
173182
[__link7]: https://github.com/hyperium/hyper
174183
[__link8]: https://github.com/hyperium/hyper
175-
[__link9]: https://github.com/hyperium/hyper
184+
[__link9]: https://github.com/alexcrichton/curl-rust
176185

influxdb/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ http = "0.2.4"
2323
influxdb_derive = { version = "0.5.1", optional = true }
2424
lazy-regex = "3.1"
2525
reqwest = { version = "0.11.4", default-features = false, optional = true }
26-
surf = { version = "2.2.0", default-features = false, optional = true }
2726
serde = { version = "1.0.186", optional = true }
2827
serde_derive = { version = "1.0.186", optional = true }
2928
serde_json = { version = "1.0.48", optional = true }
@@ -35,16 +34,10 @@ derive = ["dep:influxdb_derive"]
3534
serde = ["dep:serde", "dep:serde_derive", "dep:serde_json"]
3635

3736
# http clients
38-
curl-client = ["surf", "surf/curl-client"]
39-
h1-client = ["surf", "surf/h1-client"]
40-
h1-client-rustls = ["surf", "surf/h1-client-rustls"]
41-
hyper-client = ["surf", "surf/hyper-client"]
4237
reqwest-client-rustls = ["reqwest", "reqwest/rustls-tls-webpki-roots"]
4338
reqwest-client-native-tls = ["reqwest", "reqwest/native-tls-alpn"]
4439
reqwest-client-native-tls-vendored = ["reqwest", "reqwest/native-tls-vendored"]
45-
wasm-client = ["surf", "surf/wasm-client"]
4640

4741
[dev-dependencies]
48-
async-std = { version = "1.6.5", features = ["attributes", "tokio02", "tokio1"] }
4942
indoc = "1.0"
5043
tokio = { version = "1.7", features = ["macros", "rt-multi-thread"] }

influxdb/src/client/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use reqwest::{Client as HttpClient, RequestBuilder, Response as HttpResponse};
2121
use std::collections::{BTreeMap, HashMap};
2222
use std::fmt::{self, Debug, Formatter};
2323
use std::sync::Arc;
24-
#[cfg(feature = "surf")]
25-
use surf::{Client as HttpClient, RequestBuilder, Response as HttpResponse};
2624

2725
use crate::query::QueryType;
2826
use crate::Error;
@@ -178,11 +176,6 @@ impl Client {
178176
)
179177
};
180178

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-
186179
Ok((build.unwrap().to_owned(), version.unwrap().to_owned()))
187180
}
188181

@@ -254,11 +247,6 @@ impl Client {
254247
}
255248
};
256249

257-
#[cfg(feature = "surf")]
258-
let request_builder = request_builder.map_err(|err| Error::UrlConstructionError {
259-
error: err.to_string(),
260-
})?;
261-
262250
let res = self
263251
.auth_if_needed(request_builder)
264252
.send()
@@ -270,10 +258,6 @@ impl Client {
270258

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

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

influxdb/src/integrations/serde_integration/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -160,10 +155,6 @@ impl Client {
160155

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

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

influxdb/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@
7979
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "reqwest-client-native-tls")]
8080
//! - **[hyper](https://github.com/hyperium/hyper)** (through reqwest), with vendored native TLS (OpenSSL)
8181
#![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")]
8482
//! - **[curl](https://github.com/alexcrichton/curl-rust)**, using [libcurl](https://curl.se/libcurl/)
8583
#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "curl-client")]
8684
//! - **[async-h1](https://github.com/http-rs/async-h1)** with native TLS (OpenSSL)
@@ -128,12 +126,6 @@ macro_rules! cargo_toml_private {
128126
}
129127
use cargo_toml_private;
130128

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-
137129
mod client;
138130
mod error;
139131
mod query;

0 commit comments

Comments
 (0)