diff options
author | hozan23 <hozan23@karyontech.net> | 2024-06-13 05:52:48 +0200 |
---|---|---|
committer | hozan23 <hozan23@karyontech.net> | 2024-06-13 05:52:48 +0200 |
commit | 1c27f751c30196e2c421ae420dacbc4ff25f0fc7 (patch) | |
tree | e9a34bea9e6fd45d53a4ad1a7a4e75857ad2fe9a /jsonrpc/examples | |
parent | d6a280f69a6685d5b4da5366626fb76a27f0cc07 (diff) |
jsonrpc: spread out comments and clean up
Diffstat (limited to 'jsonrpc/examples')
-rw-r--r-- | jsonrpc/examples/pubsub_server.rs | 8 | ||||
-rw-r--r-- | jsonrpc/examples/tokio_server/Cargo.lock | 8 | ||||
-rw-r--r-- | jsonrpc/examples/tokio_server/src/main.rs | 12 |
3 files changed, 12 insertions, 16 deletions
diff --git a/jsonrpc/examples/pubsub_server.rs b/jsonrpc/examples/pubsub_server.rs index bae5b37..74eb907 100644 --- a/jsonrpc/examples/pubsub_server.rs +++ b/jsonrpc/examples/pubsub_server.rs @@ -4,9 +4,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use karyon_core::async_util::sleep; -use karyon_jsonrpc::{ - message::SubscriptionID, rpc_impl, rpc_pubsub_impl, ArcChannel, Error, Server, -}; +use karyon_jsonrpc::{message::SubscriptionID, rpc_impl, rpc_pubsub_impl, Channel, Error, Server}; struct Calc {} @@ -30,7 +28,7 @@ impl Calc { impl Calc { async fn log_subscribe( &self, - chan: ArcChannel, + chan: Arc<Channel>, method: String, _params: Value, ) -> Result<Value, Error> { @@ -52,7 +50,7 @@ impl Calc { async fn log_unsubscribe( &self, - chan: ArcChannel, + chan: Arc<Channel>, _method: String, params: Value, ) -> Result<Value, Error> { diff --git a/jsonrpc/examples/tokio_server/Cargo.lock b/jsonrpc/examples/tokio_server/Cargo.lock index 16926fc..bd7d714 100644 --- a/jsonrpc/examples/tokio_server/Cargo.lock +++ b/jsonrpc/examples/tokio_server/Cargo.lock @@ -663,7 +663,7 @@ dependencies = [ [[package]] name = "karyon_core" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel", "bincode", @@ -680,7 +680,7 @@ dependencies = [ [[package]] name = "karyon_jsonrpc" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel", "async-trait", @@ -698,7 +698,7 @@ dependencies = [ [[package]] name = "karyon_jsonrpc_macro" -version = "0.1.0" +version = "0.1.1" dependencies = [ "proc-macro2", "quote", @@ -708,7 +708,7 @@ dependencies = [ [[package]] name = "karyon_net" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel", "async-trait", diff --git a/jsonrpc/examples/tokio_server/src/main.rs b/jsonrpc/examples/tokio_server/src/main.rs index 3bb4871..0a47fda 100644 --- a/jsonrpc/examples/tokio_server/src/main.rs +++ b/jsonrpc/examples/tokio_server/src/main.rs @@ -3,9 +3,7 @@ use std::{sync::Arc, time::Duration}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use karyon_jsonrpc::{ - message::SubscriptionID, rpc_impl, rpc_pubsub_impl, ArcChannel, Error, Server, -}; +use karyon_jsonrpc::{message::SubscriptionID, rpc_impl, rpc_pubsub_impl, Channel, Error, Server}; struct Calc { version: String, @@ -45,16 +43,16 @@ impl Calc { impl Calc { async fn log_subscribe( &self, - chan: ArcChannel, + chan: Arc<Channel>, method: String, _params: Value, ) -> Result<Value, Error> { let sub = chan.new_subscription(&method).await; - let sub_id = sub.id.clone(); + let sub_id = sub.id; tokio::spawn(async move { loop { tokio::time::sleep(std::time::Duration::from_secs(1)).await; - if let Err(_) = sub.notify(serde_json::json!("Hello")).await { + if sub.notify(serde_json::json!("Hello")).await.is_err() { break; } } @@ -65,7 +63,7 @@ impl Calc { async fn log_unsubscribe( &self, - chan: ArcChannel, + chan: Arc<Channel>, _method: String, params: Value, ) -> Result<Value, Error> { |