feat(client): allow to specify a specific remote adress on client request#1169
feat(client): allow to specify a specific remote adress on client request#1169
Conversation
5f96fec to
e010e00
Compare
e010e00 to
4c8fc50
Compare
4c8fc50 to
401badf
Compare
|
Wouldn't make more sense to just overwrite the uri accordingly for use case like this? That way your logic is not bound to any http client crate and can be self contained in |
|
It depends on the use case: actually the host in the uri will do 3 things :
I have use case where i may need different value for this 3 behavior :
So changing it in the url would break other behavior (not the correct host / sni on the targeted backend as an example) Our current use case is that we are building a proxy server where our client can configure this 3 fields independently since some of them have this need, (was already the case when using another lib, but there was a lot of hack to make this configurable) |
|
We are very careful when extending http types. Reason being they are already large with big memory footprint which can be problematic when moving the ownership around. (compiler can have difficulty eliding memory copy) Any type bloat for niche use case would be an overhead for otherwise and for now I would suggest using extension together with a customized resolver for it. We can look into how resolver's API can be reworked to co-op with it. |
|
My main problem on the resolve API for that is that it happens after fetching the connection from the pool Which means, even if i use an extension point and we allow custom resolver to look at extensions, if i have 2 requests on the same host but with a different address extension, the second one will use the connection of the first one (since connection was already existing). I began to look at changing this order (first resolve, then pool based on resolved socket address) but not sure if you want to allow that since it's a pretty big change in terms of how things work for the client. |
|
Also this means that current client will not handle DNS change if there is an existing connection until the connection is dropped |
|
We can also look into the pool api and it's interaction with resolver. My guess is it's OK to outsource fast DNS look up to user implemented resolver and do unconditional look up for ever request. As for dns changes infecting connection pool it would be another story for another issue. |
|
I have been looking into making connection pool into a generic service that can be provided by user code. It would help to enable this use case of conditional override of pooling and/or customized connection object and it's identifier. |
|
I think it would, I was also thinking that it would be the best approach. I think the best approach would be for the client to depend on a service that gives us a stream from the request, something like
where Then resolve + pool + connection creating could be delegated to this service (and we could define our own if it's possible) This would allow a lot of features that may not be suitable here but could be implemented by replacing those services (such as load balancing / forcing socket address / specific connection implementation / etc ...) |
401badf to
cf4f145
Compare
This add the possibility to set a specific socket address for a request which can be useful during testing or when you already know the target server ip address / port