Open sosthene-nitrokey opened 2 months ago
Interesting!
The last thing I did was to make it possible to override the AgenConfig settings per request.
It strikes me that this is somewhat related to the max_idle_age
setting. Meaning if you set that to 0, you should get a fresh connection every time. We should maybe tweak the internals a bit to ensure this is indeed the behavior we get.
That's great, but I don't think this solves this case. Sometimes you would know that no requests will happen for a while and want to close idle connections to not waste resources, and sending a new request with max_idle_age
to zero
for that seems wasteful.
@sosthene-nitrokey but then an Agent is quite cheap to create, so you could just drop the entire instance. The AgentConfig
is cloneable, so you can configure it once and do .into()
to get a new Agent up.
There is no AgentConfig
in the released ureq. Is it a 3.0 thing?
In 2.x the current AgentBuilder is not clonable.
There is also the issue that if the agent is cloned around, changing the agent needs an additional mechanism to ensure all instances are modified too. Something like arc-swap.
Sorry, yeah. My mind is in 3.x land.
There are some situations (firewall for example), where it is desirable to clear all connections in the pool. For example after a IO error in a request, one might want to clear all the connections in the pool to ensure that the error was not due to the connection being stale.
This feature request would be to add the following method to
Agent
:See this implementation for our own fork of ureq based on the 2.0 branch.