Skip to content

pool: introduce generic Key parameter #16

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

Merged
merged 4 commits into from
Dec 16, 2022

Conversation

howardjohn
Copy link
Contributor

@howardjohn howardjohn commented Dec 15, 2022

This PR makes pooling generic over the Key type, so the caller can decide how they wish to pool the client connections.

This PR builds on the work done by @EItanya (my colleague who is going OOO for a bit, so I took over) in #12.

Since that PR, support for the runtime feature was introduced, and a blanket impl was added for Key (see #12 (comment)).

With this and #15 pulled locally, I was able to get a full custom pooling implementation in our project. edit: actually only can pool with Reservation::Unique at this point since SendRequest isn't Clone and into_http2() is private. But those can be addressed I think.

@seanmonstar seanmonstar merged commit 287b1f9 into hyperium:master Dec 16, 2022
howardjohn added a commit to howardjohn/hyper-util that referenced this pull request Jun 9, 2025
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 added a commit to howardjohn/hyper-util that referenced this pull request Jun 9, 2025
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.
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.

3 participants