aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/README.md
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-21 22:45:17 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-21 22:45:17 +0200
commit9aa972dd83a85cec5da71e8e893eb6e07d5db8ca (patch)
treea227c66e3e75e018f480556e1d58d40306acb12e /jsonrpc/README.md
parent8fc494d2d508f0e0beefccda31d15a5e387a9791 (diff)
jsonrpc/client: fix subscription error when the subscriber cannot keep up
Add a limit for receiving notifications for the subscription. If this limit is exceeded, the client will stop and raise an error. The limit is configurable when building a new client.
Diffstat (limited to 'jsonrpc/README.md')
-rw-r--r--jsonrpc/README.md11
1 files changed, 6 insertions, 5 deletions
diff --git a/jsonrpc/README.md b/jsonrpc/README.md
index 4f016b4..ca0a212 100644
--- a/jsonrpc/README.md
+++ b/jsonrpc/README.md
@@ -112,16 +112,17 @@ async {
.await
.expect("send a request");
- let (sub_id, sub) = client
+ let sub = client
.subscribe("HelloWorld.log_subscribe", ())
.await
.expect("Subscribe to log_subscribe method");
+ let sub_id = sub.id();
smol::spawn(async move {
- sub.for_each(|m| {
- println!("Receive new notification: {m}");
- })
- .await
+ loop {
+ let m = sub.recv().await.expect("Receive new log msg");
+ println!("Receive new log {m}");
+ }
})
.detach();