Skip to content

client: support custom pool keys #204

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

howardjohn
Copy link
Contributor

@howardjohn howardjohn commented Jun 9, 2025

This PR introduces the ability to use a custom pool key with the legacy Client.

#16 added generic support to Pool itself long ago, but it was never fully finished to allow a custom key in Client.

To support backwards compatibility, a default PoolKey is assigned to the generic parameter which seems reasonably backwards compatible(?)

When providing a custom pool key, the user is required to also pass a constructor that generates the pool key from the http::request::Parts.

I had also considered making a user pass in the PoolKey as part of the request() call, but I think this is a worse experience generally and harder to be backwards compatible. If a user did want to do a per-request key they can always set an extension in Parts so this approach is equally flexible. Edit: actually in my POC I realized this was not quite right. With this change, the user can pool based on anything... but then they cannot actually get utilize the extra info in the pool key during the Connector. I am still exploring some possibilities there.

This PR introduces the ability to use a custom pool key with the legacy
Client.

hyperium#16 added generic support to
`Pool` itself long ago, but it was never fully finished to allow a
custom key in `Client`.

To support backwards compatibility, a default PoolKey is assigned to the
generic parameter which seems reasonably backwards compatible(?)

When providing a custom pool key, the user is required to also pass a
constructor that generates the pool key from the `http::request::Parts`.
I had also considered making a user pass in the PoolKey as part of the
`request()` call, but I think this is a worse experience generally and
harder to be backwards compatible. If a user did want to do a
per-request key they can always set an extension in `Parts` so this
approach is equally flexible.
@howardjohn howardjohn force-pushed the client/custom-pool-key branch from b3f356a to 9f31e38 Compare June 9, 2025 23:53
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.

1 participant