Unverified Commit 7aeb95de authored by Niklas Adolfsson's avatar Niklas Adolfsson Committed by GitHub
Browse files

prepare for client release (#215)



* prep for client release.

* fix nits

* add changelogs

* Update http-client/src/lib.rs

Co-authored-by: David's avatarDavid <dvdplm@gmail.com>

* address grumbles: one changelog

* 0.2.0-alpha

* revert rust2018 lint

Co-authored-by: David's avatarDavid <dvdplm@gmail.com>
parent 50d8bf78
......@@ -12,10 +12,10 @@ async-std = "1.9"
env_logger = "0.8"
futures = "0.3"
log = "0.4"
jsonrpsee-types = { path = "../types", version = "0.1" }
jsonrpsee-http-client = { path = "../http-client", version = "0.1" }
jsonrpsee-ws-client = { path = "../ws-client", version = "0.1" }
jsonrpsee-ws-server = { path = "../ws-server", version = "0.1" }
jsonrpsee-http-server = { path = "../http-server", version = "0.1" }
jsonrpsee-proc-macros = { path = "../proc-macros", version = "0.2" }
jsonrpsee-types = { path = "../types" }
jsonrpsee-http-client = { path = "../http-client" }
jsonrpsee-ws-client = { path = "../ws-client" }
jsonrpsee-ws-server = { path = "../ws-server" }
jsonrpsee-http-server = { path = "../http-server" }
jsonrpsee-proc-macros = { path = "../proc-macros" }
tokio = { version = "1", features = ["full"] }
[package]
name = "jsonrpsee-http-client"
version = "0.1.0"
version = "0.2.0-alpha"
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "HTTP client for JSON-RPC"
edition = "2018"
......@@ -11,8 +11,8 @@ async-trait = "0.1"
futures = "0.3"
hyper14 = { package = "hyper", version = "0.14", features = ["client", "http1", "http2", "tcp"], optional = true }
hyper13 = { package = "hyper", version = "0.13", optional = true }
jsonrpsee-types = { path = "../types", version = "0.1" }
jsonrpsee-utils = { path = "../utils", version = "0.1", default-features = false, optional = true }
jsonrpsee-types = { path = "../types", version = "0.2.0-alpha" }
jsonrpsee-utils = { path = "../utils", version = "0.2.0-alpha", default-features = false, optional = true }
log = "0.4"
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
......
......@@ -7,8 +7,7 @@ use std::convert::TryInto;
use std::sync::atomic::{AtomicU64, Ordering};
/// JSON-RPC HTTP Client that provides functionality to perform method calls and notifications.
///
/// WARNING: The async methods must be executed on [Tokio 1.0](https://docs.rs/tokio/1.0.1/tokio).
#[derive(Debug)]
pub struct HttpClient {
/// HTTP transport client.
transport: HttpTransportClient,
......
#![warn(missing_debug_implementations, missing_docs, unreachable_pub)]
//! # jsonrpsee-http-client
//!
//! `jsonrpsee-http-client` is [JSON RPC](https://www.jsonrpc.org/specification) HTTP client library that's is built for `async/await`.
//!
//! It is tightly-coupled to [`tokio`](https://docs.rs/tokio) because [`hyper`](https://docs.rs/hyper) is used as transport client,
//! which is not compatible with other async runtimes such as
//! [`async-std`](https://docs.rs/async-std/), [`smol`](https://docs.rs/smol) and similar.
//!
//! It supports both [`tokio 1.0`](https://docs.rs/tokio/1.2.0/tokio/) and [`tokio 0.2`](https://docs.rs/tokio/0.2.25/tokio/index.html)
//! via [Optional features](#optional-features).
//!
//! # Optional Features
//!
//! `jsonrpsee-http-client` uses the following [feature flags]:
//!
//! - `tokio1`: Enable to use the library with [`tokio 1.0`](https://docs.rs/tokio/1.2.0/tokio/) (mutually exclusive with `tokio02`)
//! - `tokio0.2`: Enable to use the library with [`tokio 0.2`](https://docs.rs/tokio/0.2.25/tokio/index.html) (mutually exclusive with `tokio1`)
//!
//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
#[cfg(all(feature = "tokio1", feature = "tokio02"))]
compile_error!("feature `tokio1` and `tokio02` are mutably exclusive");
......
[package]
name = "jsonrpsee-http-server"
version = "0.1.0"
version = "0.2.0-alpha"
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "HTTP server for JSON-RPC"
edition = "2018"
......@@ -11,8 +11,8 @@ async-std = "1.8"
futures = "0.3"
fnv = "1"
hyper = { version = "0.14", features = ["stream", "client", "server", "http1", "http2", "tcp"] }
jsonrpsee-types = { path = "../types", version = "0.1" }
jsonrpsee-utils = { path = "../utils", version = "0.1" }
jsonrpsee-types = { path = "../types", version = "0.2.0-alpha" }
jsonrpsee-utils = { path = "../utils", version = "0.2.0-alpha" }
log = "0.4"
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
......
[package]
name = "jsonrpsee-proc-macros"
description = "JSON-RPC crate"
version = "0.2.0"
description = "Procedueral macros for jsonrpsee"
version = "0.2.0-alpha"
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
license = "MIT"
edition = "2018"
......
[package]
name = "jsonrpsee-types"
version = "0.1.0"
version = "0.2.0-alpha"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Shared types for jsonrpsee"
edition = "2018"
......
......@@ -17,6 +17,7 @@ pub struct Subscription<Notif> {
}
/// Message that the Client can send to the background task.
#[derive(Debug)]
pub enum FrontToBack {
/// Send a one-shot notification to the server. The server doesn't give back any feedback.
Notification {
......
[package]
name = "jsonrpsee-utils"
version = "0.1.0"
version = "0.2.0-alpha"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Utilities for jsonrpsee"
edition = "2018"
......@@ -11,7 +11,7 @@ futures = "0.3"
globset = "0.4"
hyper13 = { package = "hyper", version = "0.13", default-features = false, features = ["stream"], optional = true }
hyper14 = { package = "hyper", version = "0.14", default-features = false, features = ["stream"], optional = true }
jsonrpsee-types = { path = "../types", version = "0.1" }
jsonrpsee-types = { path = "../types", version = "0.2.0-alpha" }
lazy_static = "1.4"
log = "0.4"
unicase = "2.6"
......
[package]
name = "jsonrpsee-ws-client"
version = "0.1.0"
version = "0.2.0-alpha"
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "WebSocket client for JSON-RPC"
edition = "2018"
......@@ -12,7 +12,7 @@ async-std = { version = "1.8", features = ["attributes"] }
async-tls = "0.11"
fnv = "1"
futures = "0.3"
jsonrpsee-types = { path = "../types", version = "0.1" }
jsonrpsee-types = { path = "../types", version = "0.2.0-alpha" }
log = "0.4"
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
......
......@@ -46,7 +46,7 @@ use std::{io, marker::PhantomData};
/// Client that can be cloned.
///
/// > **Note**: This struct is designed to be easy to use, but it works by maintaining a background task running in parallel.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct WsClient {
/// Channel to send requests to the background task.
to_back: mpsc::Sender<FrontToBack>,
......
......@@ -16,6 +16,7 @@ pub async fn websocket_connection(config: WsConfig<'_>) -> Result<(Sender, Recei
/// JSONRPC WebSocket sender.
/// It's a wrapper over `WebSocket sender` with additional `JSONRPC request_id`.
#[derive(Debug)]
pub struct Sender {
request_id: u64,
transport: transport::Sender,
......@@ -93,6 +94,7 @@ impl Sender {
}
/// JSONRPC WebSocket receiver.
#[derive(Debug)]
pub struct Receiver {
transport: transport::Receiver,
}
......
#![warn(missing_debug_implementations, missing_docs, unreachable_pub)]
//! # jsonrpsee-ws-client
//!
//! `jsonrpsee-ws-client` is a [JSON RPC](https://www.jsonrpc.org/specification) WebSocket client library that's is built for `async/await`.
/// WebSocket Client.
pub mod client;
/// JSONRPC WebSocket transport.
......
......@@ -14,12 +14,14 @@ use jsonrpsee_types::{
};
use std::collections::hash_map::{Entry, HashMap};
#[derive(Debug)]
enum Kind {
PendingMethodCall(PendingCallOneshot),
PendingSubscription((PendingSubscriptionOneshot, UnsubscribeMethod)),
Subscription((SubscriptionSink, UnsubscribeMethod)),
}
#[derive(Debug)]
/// Indicates the status of a given request/response.
pub enum RequestStatus {
/// The method call is waiting for a response,
......@@ -38,6 +40,7 @@ type SubscriptionSink = mpsc::Sender<JsonValue>;
type UnsubscribeMethod = String;
type RequestId = u64;
#[derive(Debug, Default)]
/// Manages and monitors JSONRPC v2 method calls and subscriptions.
pub struct RequestManager {
/// List of requests that are waiting for a response from the server.
......@@ -48,8 +51,9 @@ pub struct RequestManager {
}
impl RequestManager {
/// Create an empty `RequestManager`.
pub fn new() -> Self {
Self { requests: FnvHashMap::default(), subscriptions: HashMap::new() }
Self::default()
}
/// Tries to insert a new pending call.
......
......@@ -33,6 +33,7 @@ use futures::{
use pin_project::pin_project;
use std::{io::Error as IoError, pin::Pin, task::Context, task::Poll};
/// Stream to represent either a unencrypted or encrypted socket stream.
#[pin_project(project = EitherStreamProj)]
#[derive(Debug, Copy, Clone)]
pub enum EitherStream<S, T> {
......
......@@ -42,22 +42,26 @@ type TlsOrPlain = crate::stream::EitherStream<TcpStream, TlsStream<TcpStream>>;
pub struct Host(String);
impl Host {
/// Extracts a string slice from the inner String.
pub fn as_str(&self) -> &str {
self.0.as_str()
}
}
/// Sending end of WebSocket transport.
#[derive(Debug)]
pub struct Sender {
inner: connection::Sender<BufReader<BufWriter<TlsOrPlain>>>,
}
/// Receiving end of WebSocket transport.
#[derive(Debug)]
pub struct Receiver {
inner: connection::Receiver<BufReader<BufWriter<TlsOrPlain>>>,
}
/// Builder for a WebSocket transport [`Sender`] and [`Receiver`] pair.
/// Builder for a WebSocket transport [`Sender`] and ['Receiver`] pair.
#[derive(Debug)]
pub struct WsTransportClientBuilder<'a> {
/// Socket addresses to try to connect to.
sockaddrs: Vec<SocketAddr>,
......
[package]
name = "jsonrpsee-ws-server"
version = "0.1.0"
version = "0.2.0-alpha"
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "WebSocket server for JSON-RPC"
edition = "2018"
......@@ -13,7 +13,7 @@ beef = "0.5"
bs58 = "0.4"
fnv = "1"
futures = "0.3"
jsonrpsee-types = { path = "../types", version = "0.1" }
jsonrpsee-types = { path = "../types", version = "0.2.0-alpha" }
log = "0.4"
parking_lot = "0.11"
rand = "0.8"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment