Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f009918
extract ws client to async client
niklasad1 Nov 26, 2021
ca51994
bring back jsonrpsee-ws-client crate
niklasad1 Nov 29, 2021
dc4c1ab
new crate core client
niklasad1 Nov 29, 2021
c6d0f6b
add missing file
niklasad1 Nov 29, 2021
6d7ea12
jsonrpsee crate: add core client
niklasad1 Nov 30, 2021
707cadc
rexport core client
niklasad1 Nov 30, 2021
c6d2b81
more re-exports
niklasad1 Nov 30, 2021
aee6be3
downgrade trait bounds
niklasad1 Nov 30, 2021
b7641f9
Merge remote-tracking branch 'origin/master' into extract-async-client
niklasad1 Dec 15, 2021
964f8d9
update version
niklasad1 Dec 15, 2021
485b4ed
fix nits
niklasad1 Dec 15, 2021
b5bf6f8
send close reason
niklasad1 Dec 15, 2021
eafa050
Update types/src/traits.rs
niklasad1 Dec 15, 2021
c048971
Merge remote-tracking branch 'origin/master' into extract-async-client
niklasad1 Dec 20, 2021
5f34cbc
move 'TEN_MB_CONST' to core
niklasad1 Dec 20, 2021
b124026
Update client/core-client/Cargo.toml
niklasad1 Dec 20, 2021
d110400
Update client/core-client/src/lib.rs
niklasad1 Dec 20, 2021
9dde491
cargo fmt
niklasad1 Dec 20, 2021
2487948
Merge remote-tracking branch 'origin/extract-async-client' into extra…
niklasad1 Dec 20, 2021
ed8293a
Update client/ws-client/src/lib.rs
niklasad1 Dec 20, 2021
2a4e7b6
Update client/ws-client/src/lib.rs
niklasad1 Dec 20, 2021
0dab419
move `async-client` core
niklasad1 Dec 20, 2021
e6d162d
Merge remote-tracking branch 'origin/extract-async-client' into extra…
niklasad1 Dec 20, 2021
f81e172
fix docs
niklasad1 Dec 20, 2021
973b9ed
add example how to use "core client"
niklasad1 Dec 20, 2021
0c6f571
fix build
niklasad1 Dec 20, 2021
aee4a44
Update http-server/Cargo.toml
niklasad1 Dec 20, 2021
632085f
Update client/transport/Cargo.toml
dvdplm Dec 20, 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
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
members = [
"examples",
"benches",
"http-client",
"http-server",
"test-utils",
"jsonrpsee",
"tests",
"types",
"core",
"ws-client",
"ws-server",
"client/ws-client",
"client/http-client",
"client/transport",
"proc-macros",
]
resolver = "2"
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jsonrpsee-benchmarks"
version = "0.6.0"
version = "0.6.1"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Benchmarks for jsonrpsee"
edition = "2018"
Expand Down
16 changes: 11 additions & 5 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use criterion::*;
use futures_util::future::join_all;
use helpers::{SUB_METHOD_NAME, UNSUB_METHOD_NAME};
use jsonrpsee::core::client::{Client, SubscriptionClient};
use jsonrpsee::core::client::{ClientT, SubscriptionClientT};
use jsonrpsee::http_client::HttpClientBuilder;
use jsonrpsee::types::{Id, ParamsSer, RequestSer};
use jsonrpsee::ws_client::WsClientBuilder;
Expand Down Expand Up @@ -132,15 +132,21 @@ impl RequestBencher for AsyncBencher {
const REQUEST_TYPE: RequestType = RequestType::Async;
}

fn run_round_trip(rt: &TokioRuntime, crit: &mut Criterion, client: Arc<impl Client>, name: &str, request: RequestType) {
fn run_round_trip(
rt: &TokioRuntime,
crit: &mut Criterion,
client: Arc<impl ClientT>,
name: &str,
request: RequestType,
) {
crit.bench_function(&request.group_name(name), |b| {
b.to_async(rt).iter(|| async {
black_box(client.request::<String>(request.method_name(), None).await.unwrap());
})
});
}

fn run_sub_round_trip(rt: &TokioRuntime, crit: &mut Criterion, client: Arc<impl SubscriptionClient>, name: &str) {
fn run_sub_round_trip(rt: &TokioRuntime, crit: &mut Criterion, client: Arc<impl SubscriptionClientT>, name: &str) {
let mut group = crit.benchmark_group(name);
group.bench_function("subscribe", |b| {
b.to_async(rt).iter_with_large_drop(|| async {
Expand Down Expand Up @@ -188,7 +194,7 @@ fn run_sub_round_trip(rt: &TokioRuntime, crit: &mut Criterion, client: Arc<impl
fn run_round_trip_with_batch(
rt: &TokioRuntime,
crit: &mut Criterion,
client: Arc<impl Client>,
client: Arc<impl ClientT>,
name: &str,
request: RequestType,
) {
Expand All @@ -203,7 +209,7 @@ fn run_round_trip_with_batch(
group.finish();
}

fn run_concurrent_round_trip<C: 'static + Client + Send + Sync>(
fn run_concurrent_round_trip<C: 'static + ClientT + Send + Sync>(
rt: &TokioRuntime,
crit: &mut Criterion,
client: Arc<C>,
Expand Down
8 changes: 4 additions & 4 deletions http-client/Cargo.toml → client/http-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jsonrpsee-http-client"
version = "0.6.0"
version = "0.6.1"
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "HTTP client for JSON-RPC"
edition = "2018"
Expand All @@ -14,16 +14,16 @@ async-trait = "0.1"
rustc-hash = "1"
hyper = { version = "0.14.10", features = ["client", "http1", "http2", "tcp"] }
hyper-rustls = { version = "0.23", optional = true }
jsonrpsee-types = { path = "../types", version = "0.6.0" }
jsonrpsee-core = { path = "../core", version = "0.6.0", features = ["client", "http-helpers"] }
jsonrpsee-types = { path = "../../types", version = "0.6.1" }
jsonrpsee-core = { path = "../../core", version = "0.6.1", features = ["client", "http-helpers"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
tokio = { version = "1.8", features = ["time"] }
tracing = "0.1"

[dev-dependencies]
jsonrpsee-test-utils = { path = "../test-utils" }
jsonrpsee-test-utils = { path = "../../test-utils" }
tokio = { version = "1.8", features = ["net", "rt-multi-thread", "macros"] }

[features]
Expand Down
10 changes: 5 additions & 5 deletions http-client/src/client.rs → client/http-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ use std::sync::Arc;
use std::time::Duration;

use crate::transport::HttpTransportClient;
use crate::types::{ErrorResponse, Id, NotificationSer, ParamsSer, RequestSer, Response, TEN_MB_SIZE_BYTES};
use crate::types::{ErrorResponse, Id, NotificationSer, ParamsSer, RequestSer, Response};
use async_trait::async_trait;
use jsonrpsee_core::client::{CertificateStore, Client, RequestIdManager, Subscription, SubscriptionClient};
use jsonrpsee_core::Error;
use jsonrpsee_core::client::{CertificateStore, ClientT, RequestIdManager, Subscription, SubscriptionClientT};
use jsonrpsee_core::{Error, TEN_MB_SIZE_BYTES};
use rustc_hash::FxHashMap;
use serde::de::DeserializeOwned;

Expand Down Expand Up @@ -104,7 +104,7 @@ pub struct HttpClient {
}

#[async_trait]
impl Client for HttpClient {
impl ClientT for HttpClient {
async fn notification<'a>(&self, method: &'a str, params: Option<ParamsSer<'a>>) -> Result<(), Error> {
let notif = NotificationSer::new(method, params);
let fut = self.transport.send(serde_json::to_string(&notif).map_err(Error::ParseError)?);
Expand Down Expand Up @@ -196,7 +196,7 @@ impl Client for HttpClient {
}

#[async_trait]
impl SubscriptionClient for HttpClient {
impl SubscriptionClientT for HttpClient {
/// Send a subscription request to the server. Not implemented for HTTP; will always return [`Error::HttpNotImplemented`].
async fn subscribe<'a, N>(
&self,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use crate::types::error::{ErrorCode, ErrorObject, ErrorResponse};
use crate::types::ParamsSer;
use crate::HttpClientBuilder;
use jsonrpsee_core::client::Client;
use jsonrpsee_core::client::ClientT;
use jsonrpsee_core::rpc_params;
use jsonrpsee_core::Error;
use jsonrpsee_test_utils::helpers::*;
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions client/transport/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "jsonrpsee-client-transport"
version = "0.6.1"
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "WebSocket client for JSON-RPC"
edition = "2018"
license = "MIT"
repository = "https://github.com/paritytech/jsonrpsee"
homepage = "https://github.com/paritytech/jsonrpsee"
documentation = "https://docs.rs/jsonrpsee-ws-client"

[dependencies]
jsonrpsee-types = { path = "../../types", version = "0.6.1", optional = true }
jsonrpsee-core = { path = "../../core", version = "0.6.1", features = ["client"] }
tracing = { version = "0.1", optional = true }
thiserror = { version = "1", optional = true }
futures = { version = "0.3.14", default-features = false, features = ["std"], optional = true }
http = { version = "0.2", optional = true }
tokio-util = { version = "0.6", features = ["compat"], optional = true }
tokio = { version = "1", features = ["net", "time", "macros"], optional = true }
pin-project = { version = "1", optional = true }
rustls-native-certs = { version = "0.6", optional = true }
webpki-roots = { version = "0.22", optional = true }
tokio-rustls = { version = "0.23", optional = true }

# ws
soketto = { version = "0.7.1", optional = true }

[features]
tls = ["tokio-rustls", "webpki-roots", "rustls-native-certs"]
ws = [
"futures",
"http",
"tokio",
"tokio-util",
"soketto",
"pin-project",
"jsonrpsee-types",
"thiserror",
"tracing"
]
26 changes: 4 additions & 22 deletions ws-client/src/lib.rs → client/transport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,9 @@

#![warn(missing_debug_implementations, missing_docs, unreachable_pub)]

//! # jsonrpsee-ws-client
//! # jsonrpsee-client-transports
//!
//! `jsonrpsee-ws-client` is a [JSON RPC](https://www.jsonrpc.org/specification) WebSocket client library that's is built for `async/await`.
//!
//! ## Runtime support
//!
//! This library uses `tokio` as the runtime and does not support other kinds of runtimes.

/// WebSocket Client.
pub mod client;
/// Helpers.
pub mod helpers;
/// Request manager.
pub mod manager;
/// Stream.
pub mod stream;
/// WebSocket transport.
pub mod transport;

#[cfg(test)]
mod tests;

pub use client::{WsClient, WsClientBuilder};
pub use jsonrpsee_types as types;
/// Websocket transport
#[cfg(feature = "ws")]
pub mod ws;
Loading