Skip to content

Conversation

@1911860538
Copy link
Contributor

@1911860538 1911860538 commented Dec 5, 2025

Use a shared http.Transport to enable connection reuse and prevent connection accumulation.
Previously, each NewClient() call create a new http.Transport, which led to:

  • Independent connection pools per client instance
  • Inability to reuse connections across clients
  • Connection accumulation due to keep-alive connection not being shared

In theory, NewClient should only be called once. However, users may call it multiple.
Meanwhile, to follow Go best practices, we should modify the code to reuse http.Transport.
Ref: https://github.com/golang/go/blob/master/src/net/http/client.go#L33

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 5, 2025
@1911860538
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant