Skip to content

Commit 7b797ae

Browse files
authored
Bump version (11.0) (paritytech#413)
* Bump version (11.0) * Remove macros from release script * Bump versions in readme * Add simple client examples in docs * Fix doc example * ^^^ try again * Full client/server example * Update README example to use client/server example * Client support notice at top of README
1 parent 9360dc8 commit 7b797ae

File tree

22 files changed

+161
-48
lines changed

22 files changed

+161
-48
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Rust implementation of JSON-RPC 2.0 Specification.
44
Transport-agnostic `core` and transport servers for `http`, `ipc`, `websockets` and `tcp`.
55

6+
**New!** Support for [clients](#Client-support).
7+
68
[![Build Status][travis-image]][travis-url]
79
[![Build Status][appveyor-image]][appveyor-url]
810

@@ -94,3 +96,57 @@ fn main() {
9496
let mut io = jsonrpc_core::IoHandler::new();
9597
io.extend_with(RpcImpl.to_delegate())
9698
}
99+
```
100+
101+
### Client support
102+
103+
```rust
104+
use jsonrpc_client::local;
105+
use jsonrpc_core::futures::future::{self, Future, FutureResult};
106+
use jsonrpc_core::{Error, IoHandler, Result};
107+
use jsonrpc_derive::rpc;
108+
109+
/// Rpc trait
110+
#[rpc]
111+
pub trait Rpc {
112+
/// Returns a protocol version
113+
#[rpc(name = "protocolVersion")]
114+
fn protocol_version(&self) -> Result<String>;
115+
116+
/// Adds two numbers and returns a result
117+
#[rpc(name = "add", alias("callAsyncMetaAlias"))]
118+
fn add(&self, a: u64, b: u64) -> Result<u64>;
119+
120+
/// Performs asynchronous operation
121+
#[rpc(name = "callAsync")]
122+
fn call(&self, a: u64) -> FutureResult<String, Error>;
123+
}
124+
125+
struct RpcImpl;
126+
127+
impl Rpc for RpcImpl {
128+
fn protocol_version(&self) -> Result<String> {
129+
Ok("version1".into())
130+
}
131+
132+
fn add(&self, a: u64, b: u64) -> Result<u64> {
133+
Ok(a + b)
134+
}
135+
136+
fn call(&self, _: u64) -> FutureResult<String, Error> {
137+
future::ok("OK".to_owned())
138+
}
139+
}
140+
141+
fn main() {
142+
let mut io = IoHandler::new();
143+
io.extend_with(RpcImpl.to_delegate());
144+
145+
let fut = {
146+
let (client, server) = local::connect::<gen_client::Client, _, _>(io);
147+
client.add(5, 6).map(|res| println!("5 + 6 = {}", res)).join(server)
148+
};
149+
fut.wait().unwrap();
150+
}
151+
152+
```

_automate/bump_version.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ ack "{ version = \"$PREV_DEPS" -l | \
1414
grep toml | \
1515
xargs sed -i "s/{ version = \"$PREV_DEPS/{ version = \"$NEW_DEPS/"
1616

17+
ack " = \"$PREV_DEPS" -l | \
18+
grep md | \
19+
xargs sed -i "s/ = \"$PREV_DEPS/ = \"$NEW_DEPS/"
20+
1721
cargo check

_automate/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -exu
44

5-
ORDER=(core client server-utils tcp ws ws/client http ipc stdio pubsub macros derive test)
5+
ORDER=(core client server-utils tcp ws ws/client http ipc stdio pubsub derive test)
66

77
for crate in ${ORDER[@]}; do
88
cd $crate

client/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["jsonrpc", "json-rpc", "json", "rpc", "serde"]
88
license = "MIT"
99
name = "jsonrpc-client"
1010
repository = "https://github.com/paritytech/jsonrpc"
11-
version = "10.1.0"
11+
version = "11.0.0"
1212

1313
categories = [
1414
"asynchronous",
@@ -21,13 +21,13 @@ categories = [
2121
[dependencies]
2222
failure = "0.1"
2323
futures = "~0.1.6"
24-
jsonrpc-core = { version = "10.1", path = "../core" }
24+
jsonrpc-core = { version = "11.0", path = "../core" }
2525
log = "0.4"
2626
serde_json = "1.0"
2727

2828
[dev-dependencies]
29-
jsonrpc-derive = { version = "10.1", path = "../derive" }
30-
jsonrpc-client = { version = "10.1", path = "." }
29+
jsonrpc-derive = { version = "11.0", path = "../derive" }
30+
jsonrpc-client = { version = "11.0", path = "." }
3131
serde = "1.0"
3232
tokio = "0.1"
3333

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["jsonrpc", "json-rpc", "json", "rpc", "serde"]
88
license = "MIT"
99
name = "jsonrpc-core"
1010
repository = "https://github.com/paritytech/jsonrpc"
11-
version = "10.1.0"
11+
version = "11.0.0"
1212

1313
categories = [
1414
"asynchronous",

derive/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ homepage = "https://github.com/paritytech/jsonrpc"
77
license = "MIT"
88
name = "jsonrpc-derive"
99
repository = "https://github.com/paritytech/jsonrpc"
10-
version = "10.1.0"
10+
version = "11.0.0"
1111

1212
[lib]
1313
proc-macro = true
@@ -19,10 +19,10 @@ quote = "0.6"
1919
proc-macro-crate = "0.1.3"
2020

2121
[dev-dependencies]
22-
jsonrpc-core = { version = "10.1", path = "../core" }
23-
jsonrpc-client = { version = "10.1", path = "../client" }
24-
jsonrpc-pubsub = { version = "10.1", path = "../pubsub" }
25-
jsonrpc-tcp-server = { version = "10.1", path = "../tcp" }
22+
jsonrpc-core = { version = "11.0", path = "../core" }
23+
jsonrpc-client = { version = "11.0", path = "../client" }
24+
jsonrpc-pubsub = { version = "11.0", path = "../pubsub" }
25+
jsonrpc-tcp-server = { version = "11.0", path = "../tcp" }
2626
log = "0.4"
2727
serde = "1.0"
2828
serde_derive = "1.0"

derive/src/lib.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,59 @@
123123
//!
124124
//! # fn main() {}
125125
//! ```
126+
//!
127+
//! Client Example
128+
//!
129+
//! ```
130+
//! use jsonrpc_client::local;
131+
//! use jsonrpc_core::futures::future::{self, Future, FutureResult};
132+
//! use jsonrpc_core::{Error, IoHandler, Result};
133+
//! use jsonrpc_derive::rpc;
134+
//!
135+
//! /// Rpc trait
136+
//! #[rpc]
137+
//! pub trait Rpc {
138+
//! /// Returns a protocol version
139+
//! #[rpc(name = "protocolVersion")]
140+
//! fn protocol_version(&self) -> Result<String>;
141+
//!
142+
//! /// Adds two numbers and returns a result
143+
//! #[rpc(name = "add", alias("callAsyncMetaAlias"))]
144+
//! fn add(&self, a: u64, b: u64) -> Result<u64>;
145+
//!
146+
//! /// Performs asynchronous operation
147+
//! #[rpc(name = "callAsync")]
148+
//! fn call(&self, a: u64) -> FutureResult<String, Error>;
149+
//! }
150+
//!
151+
//! struct RpcImpl;
152+
//!
153+
//! impl Rpc for RpcImpl {
154+
//! fn protocol_version(&self) -> Result<String> {
155+
//! Ok("version1".into())
156+
//! }
157+
//!
158+
//! fn add(&self, a: u64, b: u64) -> Result<u64> {
159+
//! Ok(a + b)
160+
//! }
161+
//!
162+
//! fn call(&self, _: u64) -> FutureResult<String, Error> {
163+
//! future::ok("OK".to_owned())
164+
//! }
165+
//! }
166+
//!
167+
//! fn main() {
168+
//! let mut io = IoHandler::new();
169+
//! io.extend_with(RpcImpl.to_delegate());
170+
//!
171+
//! let fut = {
172+
//! let (client, server) = local::connect::<gen_client::Client, _, _>(io);
173+
//! client.add(5, 6).map(|res| println!("5 + 6 = {}", res)).join(server)
174+
//! };
175+
//! fut.wait().unwrap();
176+
//! }
177+
//!
178+
//! ```
126179
127180
#![recursion_limit = "256"]
128181
#![warn(missing_docs)]

http/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ keywords = ["jsonrpc", "json-rpc", "json", "rpc", "server"]
88
license = "MIT"
99
name = "jsonrpc-http-server"
1010
repository = "https://github.com/paritytech/jsonrpc"
11-
version = "10.1.0"
11+
version = "11.0.0"
1212

1313
[dependencies]
1414
hyper = "0.12"
15-
jsonrpc-core = { version = "10.1", path = "../core" }
16-
jsonrpc-server-utils = { version = "10.1", path = "../server-utils" }
15+
jsonrpc-core = { version = "11.0", path = "../core" }
16+
jsonrpc-server-utils = { version = "11.0", path = "../server-utils" }
1717
log = "0.4"
1818
net2 = "0.2"
1919
unicase = "2.0"

http/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Rust http server using JSON-RPC 2.0.
99

1010
```
1111
[dependencies]
12-
jsonrpc-http-server = "10.0"
12+
jsonrpc-http-server = "11.0"
1313
```
1414

1515
`main.rs`

ipc/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ homepage = "https://github.com/paritytech/jsonrpc"
77
license = "MIT"
88
name = "jsonrpc-ipc-server"
99
repository = "https://github.com/paritytech/jsonrpc"
10-
version = "10.1.0"
10+
version = "11.0.0"
1111

1212
[dependencies]
1313
log = "0.4"
1414
tokio-service = "0.1"
15-
jsonrpc-core = { version = "10.1", path = "../core" }
16-
jsonrpc-server-utils = { version = "10.1", path = "../server-utils" }
15+
jsonrpc-core = { version = "11.0", path = "../core" }
16+
jsonrpc-server-utils = { version = "11.0", path = "../server-utils" }
1717
parity-tokio-ipc = "0.1"
1818
parking_lot = "0.7"
1919

0 commit comments

Comments
 (0)