MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / timeout

Function timeout

src/cluster/src/communication.rs:514–521  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

512/// goes away without resetting the connection. We assume fast same-datacenter connections, so we
513/// can choose a relatively small timeout.
514async fn timeout<F, R>(fut: F) -> anyhow::Result<R>
515where
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)]
524mod turmoil_tests {

Callers 7

handshakeFunction · 0.70
acceptFunction · 0.70
exchange_epochsFunction · 0.70
test_create_socketsFunction · 0.70
expect_frontierMethod · 0.50
await_subscribeMethod · 0.50
hello_holds_connectionFunction · 0.50

Calls

no outgoing calls

Tested by 1

test_create_socketsFunction · 0.56