rama icon indicating copy to clipboard operation
rama copied to clipboard

improve performance of EasyHttpWebClient and suport custom dns resolver

Open GlenDC opened this issue 8 months ago • 2 comments

EasyHttpWebClient currently does not allo wa custom Dns resolver, would be cool if it does.

Next to that we are currently also making a fatal mistake, depending how you put it. We are letting it create the connectors for each serve call... Which is a bit unfortunate or not needed.

Now that brings me to an idea how we can make that web client a lot more easy... I'll lay it out here but trying to keep vague / open enough to give you the creative freedom you love:

  1. EasyHttpWebClient can be be rewritten something like EasyHttpWebClient { connector: BoxedConnector } I think
  2. EasyHttpWebClient::build() will make a builder EasyHttpWebClientBuilder and that is the generic beast we deal with now as well... Which also should allow one to set a custom DnsResolver (that will be passed on the TcpConnector if defined).

Finally the EasyHttpWebClientBuilder will have a build function that will build the EasyHttpWebClient.

Also next to setting a custom http pool I think we shoud also give some builder methods for the more common http pool (or make it easier to build such a pool), because right now making such a pool is waaay to difficult and verbose (see https://github.com/plabayo/rama/issues/528)

GlenDC avatar Apr 25 '25 19:04 GlenDC

Agree that what we are doing is far from ideal. Will think about this one for some days, and then come back.

This one is also related to https://github.com/plabayo/rama/issues/498, so feel free to also assign that one to me if you want

soundofspace avatar Apr 26 '25 09:04 soundofspace

Other stuff we do not really support in such an example / ready-to-use-client while we probably should is timeouts (connection, but also for request), retryability, add required request headers, ...etc

If we indeed go for this kind builder pattern, and where EasyHttpWebClient::new() == EasyHttpWebClient::default()` just builds the default ready to use client.

That shouldn't excuse us from making our building blocks as easy to use, as in the end rama is all about building blocks, and so the goal is always that people can build their own client just as easily but for the very common client web http path we might as well make this already.

But i think for the most parts they are already easy enough to use, and where there is room of improvement it's usually just about exposing something we didn't expose yet or adding another small method or constructor. The only exception to that is the Pool provided by rama, I think there we can do a better job in making the common paths a lot easier.

GlenDC avatar Apr 26 '25 13:04 GlenDC