From 3429caa87699d986f799a11f6e0f4526e723b655 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Fri, 14 Jun 2024 22:49:53 +0200 Subject: jsonrpc: client use unbounded channels as buffer for sending requests & clean up examples --- jsonrpc/examples/pubsub_server.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'jsonrpc/examples/pubsub_server.rs') diff --git a/jsonrpc/examples/pubsub_server.rs b/jsonrpc/examples/pubsub_server.rs index 74eb907..40ea756 100644 --- a/jsonrpc/examples/pubsub_server.rs +++ b/jsonrpc/examples/pubsub_server.rs @@ -1,5 +1,6 @@ use std::{sync::Arc, time::Duration}; +use log::error; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -36,9 +37,9 @@ impl Calc { let sub_id = sub.id.clone(); smol::spawn(async move { loop { - smol::Timer::after(std::time::Duration::from_secs(1)).await; + sleep(Duration::from_millis(500)).await; if let Err(err) = sub.notify(serde_json::json!("Hello")).await { - println!("Error send notification {err}"); + error!("Error send notification {err}"); break; } } @@ -75,7 +76,7 @@ fn main() { .expect("Build a new server"); // Start the server - server.start().await; + server.start(); sleep(Duration::MAX).await; }); -- cgit v1.2.3