aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/src/server/channel.rs
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-13 05:52:48 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-13 05:52:48 +0200
commit1c27f751c30196e2c421ae420dacbc4ff25f0fc7 (patch)
treee9a34bea9e6fd45d53a4ad1a7a4e75857ad2fe9a /jsonrpc/src/server/channel.rs
parentd6a280f69a6685d5b4da5366626fb76a27f0cc07 (diff)
jsonrpc: spread out comments and clean up
Diffstat (limited to 'jsonrpc/src/server/channel.rs')
-rw-r--r--jsonrpc/src/server/channel.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/jsonrpc/src/server/channel.rs b/jsonrpc/src/server/channel.rs
index a9d1002..bb62b9f 100644
--- a/jsonrpc/src/server/channel.rs
+++ b/jsonrpc/src/server/channel.rs
@@ -4,8 +4,6 @@ use karyon_core::{async_runtime::lock::Mutex, util::random_32};
use crate::{message::SubscriptionID, Error, Result};
-pub type ArcChannel = Arc<Channel>;
-
pub(crate) struct NewNotification {
pub sub_id: SubscriptionID,
pub result: serde_json::Value,
@@ -52,7 +50,7 @@ impl Subscription {
}
}
-/// Represents a channel for creating/removing subscriptions
+/// Represents a connection channel for creating/removing subscriptions
pub struct Channel {
chan: async_channel::Sender<NewNotification>,
subs: Mutex<Vec<SubscriptionID>>,
@@ -60,7 +58,7 @@ pub struct Channel {
impl Channel {
/// Creates a new [`Channel`]
- pub(crate) fn new(chan: async_channel::Sender<NewNotification>) -> ArcChannel {
+ pub(crate) fn new(chan: async_channel::Sender<NewNotification>) -> Arc<Channel> {
Arc::new(Self {
chan,
subs: Mutex::new(Vec::new()),
@@ -75,7 +73,7 @@ impl Channel {
sub
}
- /// Removes a subscription
+ /// Removes a [`Subscription`]
pub async fn remove_subscription(&self, id: &SubscriptionID) {
let mut subs = self.subs.lock().await;
let i = match subs.iter().position(|i| i == id) {