Helper for performing network I/O under a timeout. This is meant to be used on network calls performed after a connection to a peer has been successfully established, to avoid the `create_sockets` protocol becoming stuck because a peer goes away without resetting the connection. We assume fast same-datacenter connections, so we can choose a relatively small timeout.
(fut: F)
| 512 | /// goes away without resetting the connection. We assume fast same-datacenter connections, so we |
| 513 | /// can choose a relatively small timeout. |
| 514 | async fn timeout<F, R>(fut: F) -> anyhow::Result<R> |
| 515 | where |
| 516 | F: Future<Output = std::io::Result<R>>, |
| 517 | { |
| 518 | let timeout = Duration::from_secs(1); |
| 519 | let result = mz_ore::future::timeout(timeout, fut).await?; |
| 520 | Ok(result) |
| 521 | } |
| 522 | |
| 523 | #[cfg(test)] |
| 524 | mod turmoil_tests { |
no outgoing calls