hyper
hyper copied to clipboard
Is there a way to set retry and max retry times for client request ?
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Is there a way to set the retry times for failed client requests?
And regarding the client connection settings, besides the keep-alive settings, is there a way to set an idle time to close the connection? We want to reuse the connection as much as possible, but if there is no real traffic(except for pings) within a time(say 30 mins), we want the connection to be closed.
let endpoint = tonic::transport::Endpoint::new(dst)?
.connect_timeout(Duration::from_secs(20))
.timeout(Duration::from_secs(20))
.tcp_keepalive(Option::Some(Duration::from_secs(3600)))
.http2_keep_alive_interval(Duration::from_secs(300))
.keep_alive_timeout(Duration::from_secs(20))
.keep_alive_while_idle(true);
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
In Netty, there is an IdleStateHandler which can trigger event to close the idle tcp connections. Not sure whether Hyper has a way to achieve the same effects or not.
hyper does not retry requests. Looks like you're using tonic, which integrates with tower. You can use the tower::retry middleware to do so. Define a Policy that describes what responses/errors are safe to retry, and I recommend using the Budget in the same module to implement a limit, instead of a simple counter.
We have an issue of the ways we're making generic retries better, you can follow along (and give feedback) here: https://github.com/tower-rs/tower/issues/682