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

feat(core): abstract HttpFetch trait for raw http client #5184

Merged
merged 11 commits into from
Oct 16, 2024

Conversation

everpcpc
Copy link
Contributor

Which issue does this PR close?

Closes #4471

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

core/src/raw/http_util/mod.rs Outdated Show resolved Hide resolved
core/src/raw/http_util/client.rs Outdated Show resolved Hide resolved
core/src/raw/http_util/client.rs Outdated Show resolved Hide resolved
core/src/raw/http_util/client.rs Outdated Show resolved Hide resolved
core/src/raw/http_util/client.rs Outdated Show resolved Hide resolved
core/src/raw/http_util/client.rs Outdated Show resolved Hide resolved
@everpcpc everpcpc marked this pull request as ready for review October 16, 2024 08:08
@everpcpc everpcpc requested a review from Xuanwo October 16, 2024 08:11
pub(crate) static GLOBAL_REQWEST_CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new);

/// HttpFetcher is a type erased [`HttpFetch`].
pub type HttpFetcher = Box<dyn HttpFetchDyn>;
Copy link
Member

Choose a reason for hiding this comment

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

We can use Arc<dyn HttpFetchDyn> here to eliminate the need for an extra Box.

}
}

pub trait HttpFetch: Send + Sync + Unpin + 'static {
Copy link
Member

Choose a reason for hiding this comment

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

Please add comments to this trait. This trait is exposed to users, and we expect that users should never interact with HttpFetchDyn.

}
}

impl<T: HttpFetchDyn + ?Sized> HttpFetch for Box<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Implement for Arc<T> instead.

@@ -25,6 +25,10 @@
mod client;
pub use client::HttpClient;

/// temporary client used by several features
#[allow(unused_imports)]
pub(crate) use client::GLOBAL_REQWEST_CLIENT;
Copy link
Member

Choose a reason for hiding this comment

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

Please make HttpFetch public.

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Thank you @everpcpc for working on this!

@Xuanwo Xuanwo merged commit b692223 into apache:main Oct 16, 2024
233 checks passed
@everpcpc everpcpc deleted the feat-client branch October 16, 2024 09:08
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.

Extract oio::HttpClient as a trait
3 participants