Skip to content

Commit 5e5cacc

Browse files
committed
Add more links and improve examples.
1 parent abb5e7b commit 5e5cacc

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/vision/status_quo/alan_tries_a_socket_sink.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ let ws_sender = Arc::new(Mutex::new(ws_sender));
2626
while let Some(msg) = ws_receiver.next().await {
2727
debug!("Received new WS RPC message: {:?}", msg);
2828

29-
// Echo the request:
30-
match ws_sender.lock().await.send_string(msg).await {
31-
Ok(_) => info!("New WS data sent."),
32-
Err(_) => warn!("WS connection closed."),
33-
};
29+
async_std::task::spawn(async move {
30+
let res = call_rpc(msg).await?;
31+
32+
match ws_sender.lock().await.send_string(res).await {
33+
Ok(_) => info!("New WS data sent."),
34+
Err(_) => warn!("WS connection closed."),
35+
};
36+
});
3437
}
3538
```
3639

@@ -60,8 +63,10 @@ async_std::task::spawn(async move {
6063
});
6164

6265
while let Some(msg) = ws_stream.lock().await.next().await {
63-
// Echo the request?
64-
ws_sender.send(msg);
66+
async_std::task::spawn(async move {
67+
let res = call_rpc(msg).await?;
68+
ws_sender.send(res);
69+
});
6570
}
6671
```
6772

@@ -85,7 +90,10 @@ A few weeks later, Alan's work at his project at work is merged with his new for
8590
* If there's a source of substantial disagreement, the community becomes even further fragmented, and this may cause additional confusion in newcomers.
8691
* **What are the sources for this story?**
8792
* <https://github.com/http-rs/tide-websockets>
88-
* <https://github.com/http-rs/tide-websockets/pull/17>
93+
* <https://github.com/http-rs/tide-websockets/pull/17> - Third pull request
94+
* <https://github.com/http-rs/tide-websockets/issues/15#issuecomment-797090892> - Suggestion to use a broadcast channel
95+
* <https://github.com/ChainSafe/forest/commit/ff2691bab92823a8595d1d456ed5fa9683641d76#diff-2770a30d9f259666fb470d6f11cf1851ebb2d579a1480a8173d3855572748385> - Where some of the original polling work is replaced
96+
* <https://github.com/ChainSafe/forest/blob/b9fccde00e7356a5e336665a7e482d4ef439d714/node/rpc/src/rpc_ws_handler.rs#L121> - File with Sink solution
8997
* <https://github.com/cryptoquick/tide-websockets-sink>
9098
* <https://twitter.com/cryptoquick/status/1370143022801846275>
9199
* <https://twitter.com/cryptoquick/status/1370155726056738817>

0 commit comments

Comments
 (0)