sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.51k stars 82 forks source link

Fail Fast for Certain Errors #147

Open mariotaku opened 8 months ago

mariotaku commented 8 months ago

Hi! I implemented a SSH connection pool in my project, and noticed when the connection can't be created (no route to host, failed to authenticate etc), get_timeout will actually retry until timeout.

I'd like to have an option to allow fail-fast for such case. In my fork, I added can_retry function in HandleError, and when it returns false, it will fail immediately without retry.

https://github.com/sfackler/r2d2/compare/6ab3302eeca82732a5e6c9385092fdb6e011f173...aaa2a2ba08582ad685ecdaaa74cc4ac47fe46efa

Do you think this feature makes sense? If so, I'll create a pull request.