MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / send_loop

Method send_loop

fendermint/eth/api/src/client.rs:144–164  ·  view source on GitHub ↗

Try to send something to the socket. If it fails, reconnect and send again.

(
        &self,
        mut client: WebSocketClient,
        tx: tokio::sync::oneshot::Sender<Result<T, Error>>,
        f: F,
    )

Source from the content-addressed store, hash-verified

142
143 /// Try to send something to the socket. If it fails, reconnect and send again.
144 async fn send_loop<F, T>(
145 &self,
146 mut client: WebSocketClient,
147 tx: tokio::sync::oneshot::Sender<Result<T, Error>>,
148 f: F,
149 ) -> WebSocketClient
150 where
151 F: Fn(WebSocketClient) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send>>,
152 {
153 loop {
154 match f(client.clone()).await {
155 Err(e) if matches!(e.detail(), ErrorDetail::ChannelSend(_)) => {
156 client = self.ws_client().await;
157 }
158 res => {
159 let _ = tx.send(res);
160 return client;
161 }
162 }
163 }
164 }
165
166 /// Connect to the WebSocket and start the driver, returning the client.
167 async fn ws_client(&self) -> WebSocketClient {

Callers 1

runMethod · 0.80

Calls 2

ws_clientMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected