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

Use HTTP clients with better defaults #744

Merged
merged 1 commit into from
Oct 30, 2023
Merged

Conversation

sevein
Copy link
Contributor

@sevein sevein commented Oct 30, 2023

Our existing HTTP clients are built the right way, i.e. we're creating new clients with &http.Client{} and they have a timeout set, as opposed to relying on http.DefaultClient which is shared and mutable. But in this pull request I'm proposing to use clienthttp because in addition to promoting non-global clients they come with good defaults for a couple of different scenarios: DefaultClient (for short-lived conns against arbitrary hosts) and DefaultPooledClient (for connection reuse against same hosts).

@Diogenesoftoronto
Copy link
Contributor

Our existing HTTP clients are built the right way, i.e. we're creating new clients with &http.Client{} and they have a timeout set, as opposed to relying on http.DefaultClient which is shared and mutable. But in this pull request I'm proposing to use clienthttp because in addition to promoting non-global clients they come with good defaults for a couple of different scenarios: DefaultClient (for short-lived conns against arbitrary hosts) and DefaultPooledClient (for connection reuse against same hosts).

This looks great. It always makes sense to remove globals like this, and have better defaults.

@sevein sevein merged commit 147f820 into main Oct 30, 2023
8 checks passed
@sevein sevein deleted the dev/clean-http-clients branch October 30, 2023 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants