A simple crate that helps you to retry your Future
s and Stream
s in a neat
and simple way.
```rust extern crate futuresretry; // ... use futuresretry::{RetryPolicy, StreamRetryExt};
fn handleerror(e: io::Error) -> RetryPolicy
// Use fn main() {
let listener: TcpListener = // ...
let server = listener.incoming()
.intoretry(handleerror) // Magic happens here
.andthen(|stream| {
tokio::spawn(serveconnection(stream));
Ok(())
})
.foreach(|| Ok(()))
.map_err(|e| eprintln!("Caught an error {}", e));
tokio::run(server);
}
``` Licensed under either of at your option. Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.Box<...>
instead of impl ...
if your rust version doesn't support impl Trait
.
fn serve_connection(stream: TcpStream) -> impl FutureLicense
Contribution