Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(http-client): add basic http-client implementation #216

Closed
wants to merge 5 commits into from

Conversation

matheus-consoli
Copy link
Contributor

The first implementation of a mini HTTP client based on reqwest's API

The client uses hyper, rustls, and async-std.

The client supports bytes and json (as an opt-in feature).

Depends on #215

Cargo.toml Outdated Show resolved Hide resolved
ClientBuilder::default().build()
}

pub fn get(&self, uri: impl AsRef<str>) -> RequestBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there reason for another layout of abstraction? Maybe this shouldn't be called Client, Something like ReadOnlyClient or specific purpose

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the ClientBuilder layer and moved its contents to Client itself

src/http_client/request.rs Show resolved Hide resolved
#![cfg(all(any(unix, windows), feature = "http-client-json"))]

use fluvio_future::http_client::{self, ResponseExt, StatusCode};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integrated test should not have outside dependency which could be offline or behavior changed. Please take look at other service testing. This means crate fake http server so we can control exact behavior to test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@digikata digikata Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting up a standalone https server with a root-certificate derived cert is time consuming, I suggest we mark ignore on external sites referenced in this test, and keep the https://infinyon domain sites in for this test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this supposed to be have test for previous PR. There is already sample client/server test so it should be just matter of copy/paste. Integration test should not call external service since it should be able to execute locally. If there is test to rely on external root cert then it can marked as ignore and invoke separately by CI only.

}

pub fn get(&self, uri: impl AsRef<str>) -> RequestBuilder {
let req = http::request::Builder::new().uri(Uri::from_str(uri.as_ref()).unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unwrap


use super::client::Client;

pub struct RequestBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use https://crates.io/crates/derive_builder, it's been used in the fluvio successfully

src/http_client/request.rs Show resolved Hide resolved

pub async fn send(self) -> Result<Response<Body>, Error> {
let req = self
.req_builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not set default here. Put all defaults in the builder so it's configurable. using derive_builder will simplify effort

@digikata
Copy link
Contributor

Continued on #219

@digikata digikata closed this Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants