3 ms·
OK, make an HTTP request, and if it fails, wait 2 seconds and retry. After 10 times, give up.
by Animats 10y ago
OK, make an HTTP request, and if it fails, wait 2 seconds and retry. After 10 times, give up.
- pcwalton 10y agoTimeouts are covered here. http://alexcrichton.com/futures-rs/futures/index.html#examples http://alexcrichton.com/futures-rs/futures/index.html#exampl... As for repeating something multiple times, you would either repeat the chain 10 times or write your own future combinator. Probably writing a custom future combinator would make the most sense here; actually, such a thing ought to be built-in to futures.rs.
- Animats 10y agoThat's the problem - having to roll your own control structures. IF, WHILE, and FOR cover just about everything. This semi-functional style doesn't break down into a small number of simple, well-known primitives.