hyper-rustls icon indicating copy to clipboard operation
hyper-rustls copied to clipboard

feat: builder with shared configuration

Open Fishrock123 opened this issue 1 year ago • 5 comments

Sometimes one might want to share the config to the builder api like one can to the connector api itself, allowing some optimization.

Since the config eventually get's Arc-d anyways there can be no disadvantage to this.

Fishrock123 avatar Mar 15 '24 22:03 Fishrock123

If htis is for reqwest, not sure this still make sense if it wants to just set its own fully-configured ClientConfig? This seems like a pretty niche use case and I'm not sure this is the best way to cover it.

djc avatar Mar 18 '24 09:03 djc

It wants to set it's own fully configured ClientConfig but already holds an Arc-shared reference, hence this PR.

I can imagine other clients may like this as well.

Fishrock123 avatar Mar 19 '24 20:03 Fishrock123

Updated to have pub fn with_tls_config(self, config: impl Into<Arc<ClientConfig>>) ...

Fishrock123 avatar Mar 19 '24 20:03 Fishrock123

Why does it hold an Arc-shared reference? I don't like the use of Arc::make_mut() here -- it seems weird to me to want to use the HttpConnectorBuilder for a ClientConfig that is already "shrinkwrapped" in Arc.

djc avatar Mar 20 '24 08:03 djc

Why does it hold an Arc-shared reference?

I'll have to spend more time in the codebase to answer that in an exact way - I don't know offhand, if I had to guess from past experience with Surf then connection pooling seems like a likely reason.

I could change this to use Arc::get_mut if you like, which could possibly be a better way of doing things?

Fishrock123 avatar Mar 20 '24 19:03 Fishrock123