Unverified Commit 0592442e authored by David's avatar David Committed by GitHub
Browse files

Rexport types for servers (#409)

* Include "macros" in the "server" feature

* Re-export SubscriptionSink

* Include the "types" feature in both the "client" and "server" features
Export types::* from façade when the "types" is active
Export types::* from servers

* fmt

* Export jsonrpsee_types under types

* fmt

* broken doc link

* fix benches

* fmt

* Fix test imports
parent d5d67e98
......@@ -2,13 +2,13 @@ use criterion::*;
use futures_util::future::join_all;
use helpers::{SUB_METHOD_NAME, UNSUB_METHOD_NAME};
use jsonrpsee::{
http_client::{
http_client::HttpClientBuilder,
types::traits::SubscriptionClient,
types::{
traits::Client,
v2::params::{Id, JsonRpcParams},
v2::request::JsonRpcCallSer,
HttpClientBuilder,
},
types::traits::SubscriptionClient,
ws_client::WsClientBuilder,
};
use std::sync::Arc;
......
......@@ -25,8 +25,9 @@
// DEALINGS IN THE SOFTWARE.
use jsonrpsee::{
http_client::{traits::Client, HttpClientBuilder, JsonValue},
http_client::HttpClientBuilder,
http_server::{HttpServerBuilder, RpcModule},
types::{traits::Client, JsonValue},
};
use std::net::SocketAddr;
......
......@@ -31,7 +31,8 @@
//! mutation.
use jsonrpsee::{
ws_client::{traits::SubscriptionClient, v2::params::JsonRpcParams, WsClientBuilder},
types::{traits::SubscriptionClient, v2::params::JsonRpcParams},
ws_client::WsClientBuilder,
ws_server::RpcModule,
ws_server::WsServerBuilder,
};
......
......@@ -25,7 +25,8 @@
// DEALINGS IN THE SOFTWARE.
use jsonrpsee::{
ws_client::{traits::Client, v2::params::JsonRpcParams, WsClientBuilder},
types::{traits::Client, v2::params::JsonRpcParams},
ws_client::WsClientBuilder,
ws_server::{RpcModule, WsServerBuilder},
};
use std::net::SocketAddr;
......
......@@ -25,7 +25,8 @@
// DEALINGS IN THE SOFTWARE.
use jsonrpsee::{
ws_client::{traits::SubscriptionClient, v2::params::JsonRpcParams, WsClientBuilder},
types::{traits::SubscriptionClient, v2::params::JsonRpcParams},
ws_client::WsClientBuilder,
ws_server::{RpcModule, WsServerBuilder},
};
use std::net::SocketAddr;
......
......@@ -25,8 +25,8 @@
// DEALINGS IN THE SOFTWARE.
use jsonrpsee::{
types::Error,
ws_client::{traits::SubscriptionClient, v2::params::JsonRpcParams, Subscription, WsClientBuilder},
types::{traits::SubscriptionClient, v2::params::JsonRpcParams, Error, Subscription},
ws_client::WsClientBuilder,
ws_server::{RpcModule, WsServerBuilder},
};
use std::net::SocketAddr;
......
use crate::traits::Client;
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software without restriction, including without
// limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use crate::transport::HttpTransportClient;
use crate::v2::request::{JsonRpcCallSer, JsonRpcNotificationSer};
use crate::v2::{
error::JsonRpcError,
params::{Id, JsonRpcParams},
response::JsonRpcResponse,
use crate::types::{
traits::Client,
v2::{
error::JsonRpcError,
params::{Id, JsonRpcParams},
request::{JsonRpcCallSer, JsonRpcNotificationSer},
response::JsonRpcResponse,
},
Error, TEN_MB_SIZE_BYTES,
};
use crate::{Error, TEN_MB_SIZE_BYTES};
use async_trait::async_trait;
use fnv::FnvHashMap;
use serde::de::DeserializeOwned;
......
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software without restriction, including without
// limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#![warn(missing_debug_implementations, missing_docs, unreachable_pub)]
//! # jsonrpsee-http-client
......@@ -56,4 +82,4 @@ mod tokio {
mod tests;
pub use client::{HttpClient, HttpClientBuilder};
pub use jsonrpsee_types::*;
pub use jsonrpsee_types as types;
use crate::v2::{
error::{JsonRpcError, JsonRpcErrorCode, JsonRpcErrorObject},
params::JsonRpcParams,
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software without restriction, including without
// limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use crate::types::{
traits::Client,
v2::{
error::{JsonRpcError, JsonRpcErrorCode, JsonRpcErrorObject},
params::JsonRpcParams,
},
Error, JsonValue,
};
use crate::{tokio, traits::Client, Error, HttpClientBuilder, JsonValue};
use crate::{tokio, HttpClientBuilder};
use jsonrpsee_test_utils::helpers::*;
use jsonrpsee_test_utils::types::Id;
use jsonrpsee_test_utils::TimeoutFutureExt;
......
......@@ -6,7 +6,7 @@
// that we need to be guaranteed that hyper doesn't re-use an existing connection if we ever reset
// the JSON-RPC request id to a value that might have already been used.
use crate::error::GenericTransportError;
use crate::types::error::GenericTransportError;
use hyper::client::{Client, HttpConnector};
use hyper_rustls::HttpsConnector;
use jsonrpsee_utils::hyper_helpers;
......
......@@ -40,7 +40,7 @@ pub use access_control::{
hosts::{AllowHosts, Host},
AccessControl, AccessControlBuilder,
};
pub use jsonrpsee_types::{Error, TEN_MB_SIZE_BYTES};
pub use jsonrpsee_types as types;
pub use jsonrpsee_utils::server::rpc_module::RpcModule;
pub use server::{Builder as HttpServerBuilder, Server as HttpServer, StopHandle as HttpStopHandle};
......
......@@ -24,7 +24,7 @@
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use crate::{response, AccessControl, TEN_MB_SIZE_BYTES};
use crate::{response, AccessControl};
use futures_channel::mpsc;
use futures_util::{lock::Mutex, stream::StreamExt, SinkExt};
use hyper::{
......@@ -32,10 +32,15 @@ use hyper::{
service::{make_service_fn, service_fn},
Error as HyperError,
};
use jsonrpsee_types::error::{Error, GenericTransportError};
use jsonrpsee_types::v2::error::JsonRpcErrorCode;
use jsonrpsee_types::v2::params::Id;
use jsonrpsee_types::v2::request::{JsonRpcInvalidRequest, JsonRpcNotification, JsonRpcRequest};
use jsonrpsee_types::{
error::{Error, GenericTransportError},
v2::{
error::JsonRpcErrorCode,
params::Id,
request::{JsonRpcInvalidRequest, JsonRpcNotification, JsonRpcRequest},
},
TEN_MB_SIZE_BYTES,
};
use jsonrpsee_utils::hyper_helpers::read_response_to_body;
use jsonrpsee_utils::server::rpc_module::RpcModule;
use jsonrpsee_utils::server::{
......
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software without restriction, including without
// limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#![cfg(test)]
use std::net::SocketAddr;
use crate::types::error::{CallError, Error};
use crate::{server::StopHandle, HttpServerBuilder, RpcModule};
use futures_util::FutureExt;
use jsonrpsee_test_utils::helpers::*;
use jsonrpsee_test_utils::types::{Id, StatusCode, TestContext};
use jsonrpsee_test_utils::TimeoutFutureExt;
use jsonrpsee_types::error::{CallError, Error};
use serde_json::Value as JsonValue;
use tokio::task::JoinHandle;
......
......@@ -19,7 +19,7 @@ utils = { path = "../utils", version = "0.2.0", package = "jsonrpsee-utils", opt
types = { path = "../types", version = "0.2.0", package = "jsonrpsee-types", optional = true }
[features]
client = ["http-client", "ws-client"]
server = ["http-server", "ws-server", "utils"]
client = ["http-client", "ws-client", "types"]
server = ["http-server", "ws-server", "utils", "types"]
macros = ["proc-macros", "types"]
full = ["client", "server", "macros", "utils"]
......@@ -18,14 +18,14 @@ pub use ws_server;
/// Set of RPC methods that can be mounted to the server.
#[cfg(feature = "server")]
pub use utils::server::rpc_module::RpcModule;
pub use utils::server::rpc_module::{RpcModule, SubscriptionSink};
/// Procedural macros for JSON RPC implementations.
#[cfg(feature = "macros")]
pub use proc_macros;
/// Common types used to implement JSON RPC server and client.
#[cfg(feature = "macros")]
#[cfg(any(feature = "types", feature = "macros"))]
pub mod types {
pub use ::types::*;
......
......@@ -31,8 +31,13 @@ mod helpers;
use helpers::{http_server, websocket_server, websocket_server_with_subscription};
use jsonrpsee::{
http_client::{traits::Client, Error, HttpClientBuilder},
ws_client::{traits::SubscriptionClient, v2::params::JsonRpcParams, JsonValue, Subscription, WsClientBuilder},
http_client::HttpClientBuilder,
types::{
traits::{Client, SubscriptionClient},
v2::params::JsonRpcParams,
Error, JsonValue, Subscription,
},
ws_client::WsClientBuilder,
};
use std::sync::Arc;
use std::time::Duration;
......
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software without restriction, including without
// limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//! Example of using proc macro to generate working client and server.
use std::net::SocketAddr;
......
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software without restriction, including without
// limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Not all proc macros are used let's suppress it for now.
#![allow(dead_code)]
......
......@@ -23,7 +23,7 @@ pub mod traits;
pub use async_trait::async_trait;
pub use beef::Cow;
pub use client::*;
pub use error::Error;
pub use error::{CallError, Error};
pub use serde::{de::DeserializeOwned, Serialize};
pub use serde_json::{
to_value as to_json_value, value::to_raw_value as to_json_raw_value, value::RawValue as JsonRawValue,
......
......@@ -25,22 +25,24 @@
// DEALINGS IN THE SOFTWARE.
use crate::tokio::Mutex;
use crate::traits::{Client, SubscriptionClient};
use crate::transport::{Receiver as WsReceiver, Sender as WsSender, Target, WsTransportClientBuilder};
use crate::v2::error::JsonRpcError;
use crate::v2::params::{Id, JsonRpcParams};
use crate::v2::request::{JsonRpcCallSer, JsonRpcNotification, JsonRpcNotificationSer};
use crate::v2::response::JsonRpcResponse;
use crate::TEN_MB_SIZE_BYTES;
use crate::{
helpers::call_with_timeout, manager::RequestManager, BatchMessage, Error, FrontToBack, RegisterNotificationMessage,
RequestMessage, Subscription, SubscriptionMessage,
use crate::types::{
traits::{Client, SubscriptionClient},
v2::{
error::JsonRpcError,
params::{Id, JsonRpcParams},
request::{JsonRpcCallSer, JsonRpcNotification, JsonRpcNotificationSer},
response::JsonRpcResponse,
},
BatchMessage, Error, FrontToBack, RegisterNotificationMessage, RequestMessage, Subscription, SubscriptionMessage,
TEN_MB_SIZE_BYTES,
};
use crate::{
helpers::{
build_unsubscribe_message, process_batch_response, process_error_response, process_notification,
process_single_response, process_subscription_response, stop_subscription,
build_unsubscribe_message, call_with_timeout, process_batch_response, process_error_response,
process_notification, process_single_response, process_subscription_response, stop_subscription,
},
manager::RequestManager,
transport::CertificateStore,
};
use async_trait::async_trait;
......@@ -234,7 +236,7 @@ impl<'a> WsClientBuilder<'a> {
/// Set max concurrent notification capacity for each subscription; when the capacity is exceeded the subscription will be dropped.
///
/// You can also prevent the subscription being dropped by calling [`Subscription::next()`](crate::Subscription) frequently enough
/// You can also prevent the subscription being dropped by calling [`Subscription::next()`](crate::types::Subscription) frequently enough
/// such that the buffer capacity doesn't exceeds.
///
/// **Note**: The actual capacity is `num_senders + max_subscription_capacity`
......
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