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] Allow sharing of HttpClient instances #192

Open
here-abarany opened this issue Mar 6, 2025 · 0 comments
Open

[Feature] Allow sharing of HttpClient instances #192

here-abarany opened this issue Mar 6, 2025 · 0 comments

Comments

@here-abarany
Copy link

The current implementation creates a new HttpClient instance with every new request. This is inefficient as it will:

  1. Need to spin up a new Executor each time it runs for running the HTTP request in the background.
  2. Cannot keep connections alive between requests.

To avoid HttpClient instances consuming resources longer than intended, I would propose a case class be introduced to manage an HttpClient with the client-specific parameters. A new overload of the existing request functions can be introduced that provides the client rather than the client-specific parameters (e.g. proxy, connect timeout), while the existing overloads can create a client instance on the fly as it does today. Users of the library could then opt into keeping longer-lived clients, while existing calls should behave the same as before.

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

No branches or pull requests

1 participant