Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crate restructuring #590

Merged
merged 28 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cb3e37d
Nuke V2
maciejhirsz Dec 5, 2021
09ceb90
fmt
maciejhirsz Dec 5, 2021
714ce5d
Formatting and imports
maciejhirsz Dec 9, 2021
4d79729
Merge branch 'master' of github.com:paritytech/jsonrpsee into mh-cleanup
maciejhirsz Dec 9, 2021
22dd3a7
Updated benches
maciejhirsz Dec 9, 2021
6bb0224
Fix doc comment link
maciejhirsz Dec 9, 2021
bc22ac2
Brace imports in ws-server
maciejhirsz Dec 9, 2021
392daa7
Reworking imports
maciejhirsz Dec 10, 2021
a9c37fa
Merge branch 'master' of github.com:paritytech/jsonrpsee into mh-cleanup
maciejhirsz Dec 10, 2021
57bdf5a
std first
maciejhirsz Dec 10, 2021
e24f12d
fmt
maciejhirsz Dec 10, 2021
e59732f
std on top
maciejhirsz Dec 10, 2021
4f32c88
Update to match changed line numbers
maciejhirsz Dec 10, 2021
3ec6e62
Merge branch 'master' of github.com:paritytech/jsonrpsee into mh-cleanup
maciejhirsz Dec 13, 2021
f2f5315
Rename jsonrpsee_utils -> jsonrpsee_core
maciejhirsz Dec 14, 2021
e29bdec
Migrating things types -> core
maciejhirsz Dec 14, 2021
faa0da1
RpcError -> ErrorResponse
maciejhirsz Dec 14, 2021
a9567f0
Merge types::client into core::client
maciejhirsz Dec 14, 2021
f914dca
Continued move types -> core
maciejhirsz Dec 15, 2021
6c15874
Removing features to make checks pass
maciejhirsz Dec 15, 2021
7ed2316
Move rpc_module tests to tests crate
maciejhirsz Dec 16, 2021
1d09ee4
Merge branch 'master' of github.com:paritytech/jsonrpsee into mh-cleanup
maciejhirsz Dec 16, 2021
dc4ab02
Fixed doc comment links
maciejhirsz Dec 16, 2021
394a3c2
Add futures-util dependency for client
maciejhirsz Dec 16, 2021
c38ec76
Remove dead code
maciejhirsz Dec 16, 2021
e93c2d9
fmt
maciejhirsz Dec 16, 2021
51eec24
Feature gate the Client trait
maciejhirsz Dec 17, 2021
9a88c70
Move `Client` traits to `client` module
maciejhirsz Dec 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
"jsonrpsee",
"tests",
"types",
"utils",
"core",
"ws-client",
"ws-server",
"proc-macros",
Expand Down
16 changes: 6 additions & 10 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
use std::sync::Arc;

use criterion::*;
use futures_util::future::join_all;
use helpers::{SUB_METHOD_NAME, UNSUB_METHOD_NAME};
use jsonrpsee::{
http_client::HttpClientBuilder,
types::traits::SubscriptionClient,
types::{
traits::Client,
v2::{Id, ParamsSer, RequestSer},
},
ws_client::WsClientBuilder,
};
use std::sync::Arc;
use jsonrpsee::core::traits::{Client, SubscriptionClient};
use jsonrpsee::http_client::HttpClientBuilder;
use jsonrpsee::types::{Id, ParamsSer, RequestSer};
use jsonrpsee::ws_client::WsClientBuilder;
use tokio::runtime::Runtime as TokioRuntime;

mod helpers;
Expand Down
3 changes: 2 additions & 1 deletion benches/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ pub async fn http_server(handle: tokio::runtime::Handle) -> (String, jsonrpc_htt
/// Run jsonrpc WebSocket server for benchmarks.
#[cfg(feature = "jsonrpc-crate")]
pub async fn ws_server(handle: tokio::runtime::Handle) -> (String, jsonrpc_ws_server::Server) {
use std::sync::atomic::{AtomicU64, Ordering};

use jsonrpc_pubsub::{PubSubHandler, Session, Subscriber, SubscriptionId};
use jsonrpc_ws_server::jsonrpc_core::*;
use jsonrpc_ws_server::*;
use std::sync::atomic::{AtomicU64, Ordering};

const ID: AtomicU64 = AtomicU64::new(0);

Expand Down
26 changes: 12 additions & 14 deletions utils/Cargo.toml → core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
[package]
name = "jsonrpsee-utils"
name = "jsonrpsee-core"
version = "0.6.0"
authors = ["Parity Technologies <[email protected]>"]
description = "Utilities for jsonrpsee"
edition = "2018"
license = "MIT"

[dependencies]
anyhow = "1"
arrayvec = "0.7.1"
async-trait = "0.1"
beef = { version = "0.5.1", features = ["impl_serde"] }
thiserror = { version = "1", optional = true }
futures-channel = { version = "0.3.14", default-features = false, optional = true }
thiserror = "1"
futures-channel = { version = "0.3.14", default-features = false }
futures-util = { version = "0.3.14", default-features = false, optional = true }
hyper = { version = "0.14.10", default-features = false, features = ["stream"], optional = true }
jsonrpsee-types = { path = "../types", version = "0.6.0", optional = true }
hyper = { version = "0.14.10", default-features = false, features = ["stream"] }
jsonrpsee-types = { path = "../types", version = "0.6.0" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this crate is now what the v2 was?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

tracing = { version = "0.1", optional = true }
rustc-hash = { version = "1", optional = true }
rand = { version = "0.8", optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1", features = ["raw_value"], optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1", features = ["raw_value"] }
soketto = "0.7.1"
parking_lot = { version = "0.11", optional = true }
tokio = { version = "1.8", features = ["rt"], optional = true }

[features]
default = []
http-helpers = ["hyper", "futures-util", "jsonrpsee-types"]
http-helpers = ["futures-util"]
server = [
"thiserror",
"futures-channel",
"futures-util",
"jsonrpsee-types",
"rustc-hash",
"serde",
"serde_json",
"tracing",
"parking_lot",
"rand",
"tokio",
]
client = ["jsonrpsee-types"]
client = ["futures-util"]

[dev-dependencies]
serde_json = "1.0"
Expand Down
44 changes: 34 additions & 10 deletions types/src/client.rs → core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,45 @@
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use crate::{error::SubscriptionClosed, v2::SubscriptionId, Error};
use core::marker::PhantomData;
use futures_channel::{mpsc, oneshot};
use futures_util::{
future::FutureExt,
sink::SinkExt,
stream::{Stream, StreamExt},
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue;
//! Shared utilities for `jsonrpsee` clients.
use std::pin::Pin;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
use std::task;

use crate::error::{Error, SubscriptionClosed};
use core::marker::PhantomData;
use futures_channel::{mpsc, oneshot};
use futures_util::future::FutureExt;
use futures_util::sink::SinkExt;
use futures_util::stream::{Stream, StreamExt};
use jsonrpsee_types::SubscriptionId;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue;

#[doc(hidden)]
pub mod __reexports {
pub use crate::to_json_value;
pub use jsonrpsee_types::ParamsSer;
}

#[macro_export]
/// Convert the given values to a [`jsonrpsee_types::ParamsSer`] as expected by a jsonrpsee Client (http or websocket).
macro_rules! rpc_params {
($($param:expr),*) => {
{
let mut __params = vec![];
$(
__params.push($crate::client::__reexports::to_json_value($param).expect("json serialization is infallible; qed."));
)*
Some($crate::client::__reexports::ParamsSer::Array(__params))
}
};
() => {
None
}
}

/// Subscription kind
#[derive(Debug)]
#[non_exhaustive]
Expand Down
Loading