aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-05-28 00:26:59 +0200
committerhozan23 <hozan23@karyontech.net>2024-05-28 00:26:59 +0200
commit9341e695d0e387927804716b60945912cba686dd (patch)
treecd6389124e3295931d621a7a68837bde74ff9d95 /jsonrpc
parent8afb4d30750840f66d9f97c2c54a893d3934c45e (diff)
jsonrpc: move `SubscriptionID` to message.rs
Diffstat (limited to 'jsonrpc')
-rw-r--r--jsonrpc/README.md3
-rw-r--r--jsonrpc/examples/pubsub_server.rs4
-rw-r--r--jsonrpc/src/client/mod.rs5
-rw-r--r--jsonrpc/src/lib.rs2
-rw-r--r--jsonrpc/src/message.rs4
-rw-r--r--jsonrpc/src/server/channel.rs3
6 files changed, 13 insertions, 8 deletions
diff --git a/jsonrpc/README.md b/jsonrpc/README.md
index 03f5ace..5fc6847 100644
--- a/jsonrpc/README.md
+++ b/jsonrpc/README.md
@@ -22,7 +22,8 @@ use serde_json::Value;
use smol::stream::StreamExt;
use karyon_jsonrpc::{
- Error, Server, Client, rpc_impl, rpc_pubsub_impl, SubscriptionID, ArcChannel
+ Error, Server, Client, rpc_impl, rpc_pubsub_impl, message::SubscriptionID,
+ ArcChannel
};
struct HelloWorld {}
diff --git a/jsonrpc/examples/pubsub_server.rs b/jsonrpc/examples/pubsub_server.rs
index 4b77c45..bae5b37 100644
--- a/jsonrpc/examples/pubsub_server.rs
+++ b/jsonrpc/examples/pubsub_server.rs
@@ -4,7 +4,9 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use karyon_core::async_util::sleep;
-use karyon_jsonrpc::{rpc_impl, rpc_pubsub_impl, ArcChannel, Error, Server, SubscriptionID};
+use karyon_jsonrpc::{
+ message::SubscriptionID, rpc_impl, rpc_pubsub_impl, ArcChannel, Error, Server,
+};
struct Calc {}
diff --git a/jsonrpc/src/client/mod.rs b/jsonrpc/src/client/mod.rs
index 0666ee0..05479f9 100644
--- a/jsonrpc/src/client/mod.rs
+++ b/jsonrpc/src/client/mod.rs
@@ -13,7 +13,10 @@ use karyon_core::{
};
use karyon_net::Conn;
-use crate::{message, Error, Result, SubscriptionID};
+use crate::{
+ message::{self, SubscriptionID},
+ Error, Result,
+};
const CHANNEL_CAP: usize = 10;
diff --git a/jsonrpc/src/lib.rs b/jsonrpc/src/lib.rs
index 14840fa..b7b632e 100644
--- a/jsonrpc/src/lib.rs
+++ b/jsonrpc/src/lib.rs
@@ -10,7 +10,7 @@ pub use client::{builder::ClientBuilder, Client};
pub use error::{Error, Result};
pub use server::{
builder::ServerBuilder,
- channel::{ArcChannel, Channel, Subscription, SubscriptionID},
+ channel::{ArcChannel, Channel, Subscription},
pubsub_service::{PubSubRPCMethod, PubSubRPCService},
service::{RPCMethod, RPCService},
Server,
diff --git a/jsonrpc/src/message.rs b/jsonrpc/src/message.rs
index 34d6235..1f296cd 100644
--- a/jsonrpc/src/message.rs
+++ b/jsonrpc/src/message.rs
@@ -1,7 +1,5 @@
use serde::{Deserialize, Serialize};
-use crate::SubscriptionID;
-
pub type ID = u64;
pub const JSONRPC_VERSION: &str = "2.0";
@@ -21,6 +19,8 @@ pub const INVALID_PARAMS_ERROR_CODE: i32 = -32602;
/// Internal error: Internal JSON-RPC error.
pub const INTERNAL_ERROR_CODE: i32 = -32603;
+pub type SubscriptionID = u32;
+
#[derive(Debug, Serialize, Deserialize)]
pub struct Request {
pub jsonrpc: String,
diff --git a/jsonrpc/src/server/channel.rs b/jsonrpc/src/server/channel.rs
index f14c1dd..efcd344 100644
--- a/jsonrpc/src/server/channel.rs
+++ b/jsonrpc/src/server/channel.rs
@@ -2,9 +2,8 @@ use std::sync::Arc;
use karyon_core::{async_runtime::lock::Mutex, util::random_32};
-use crate::{Error, Result};
+use crate::{message::SubscriptionID, Error, Result};
-pub type SubscriptionID = u32;
pub type ArcChannel = Arc<Channel>;
pub(crate) struct NewNotification {