Description
Is your feature request related to a problem? Please describe.
Currently I wish to use the hyper
client for http2
connection pooling, however I need to be able to pool by specific metadata. Specifically the SourceIp/Identity.
However, currently the keys in the connection pooling code are limited to a very specific set of data, specifically the protocol and the authority:
Line 58 in d32beb3
Describe the solution you'd like
I understand the the client
code is built specifically around pooling with this metadata, but if we allowed the key to be generic, rather than that specific data, it would allow reuse of the pooling code for other client implementations.
I created a branch of hyper-utils
where I tested this and mostly got it working, would love additional feedback. Here is a gist containing the pool code: https://gist.github.com/EItanya/61c4a2d67eb194e9891f7d54c2806d9d
The most important part is the addition of a second type argument to pool
, namely the key type:
pub(super) struct Pool<T, K: Eq + Hash + Clone + Debug + Unpin> {
// If the pool is disabled, this is None.
inner: Option<Arc<Mutex<PoolInner<T, K>>>>,
}
Thereby allowing the caller of this code to decide how the connections should be pooled.
This would require very few changes on the part of the hyper
client to implement as well.
Describe alternatives you've considered
The only other solution I can think of is writing it from scratch, or manually changing it heavily.
Additional context
Add any other context or screenshots about the feature request here.