Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

enable gzip compression for rpc responses #12

Open
wants to merge 149 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
9ecbf09
Extend build_rpc_trait fix to pubsub (#346)
CriesofCarrots Dec 8, 2018
0d78b8f
Add metadata to unsubscribe. (#344)
tomusdrw Dec 10, 2018
cd27b90
Test without pretty print (#347)
tomusdrw Dec 11, 2018
2ef6d92
case insensitive charset matching (#350)
seunlanlege Jan 3, 2019
3604d99
Update parking_lot requirement from 0.6 to 0.7 (#338)
dependabot[bot] Jan 4, 2019
b4d2986
travis: disable cache on Windows? (#348)
Jan 8, 2019
711ce2a
Remove extra allocation. (#353)
tomusdrw Jan 8, 2019
0227e70
Optional metadata for unsubscribe. (#352)
tomusdrw Jan 8, 2019
5fa6ad5
Fix handling multiple bound types. (#355)
tomusdrw Jan 8, 2019
24b9bef
Solve more issues with commas. (#356)
tomusdrw Jan 8, 2019
16ed9f5
Fix tokio deprecation warnings (#358)
ascjones Jan 11, 2019
789c74d
Derive Clone for all core types::* (#359)
passcod Jan 15, 2019
ec5249e
Use procedural macros (#340)
ascjones Jan 28, 2019
80205d4
Support multiple trailing arguments (#365)
svyatonik Jan 29, 2019
8160eb5
ci: bring appveyor back (#364)
Jan 29, 2019
2b47a5c
Use parity-ws-rs from crates.io (#361)
tomusdrw Jan 29, 2019
5a7be5f
Bump version of stdio (#367)
tomusdrw Jan 29, 2019
37b62a3
Migrate to edition 2018 (#368)
ascjones Jan 29, 2019
2fe3bfc
One way serialize for subscriber type (#371)
ascjones Jan 30, 2019
8ffc7f3
Add jsonrpc-derive details. (#372)
tomusdrw Jan 31, 2019
5e82ae0
Fix pieces of derive. (#374)
tomusdrw Jan 31, 2019
5234288
Fix rpc alias(es) key constant (#375)
ascjones Feb 5, 2019
c519eeb
use compile error (#382)
gui1117 Feb 7, 2019
b608779
derive: don't require pubsub dependency if no pubsub methods (#384)
ascjones Feb 8, 2019
7296443
Fail to compile with invalid attribute parameters (#385)
ascjones Feb 11, 2019
09fc608
Bump version (#386)
tomusdrw Feb 12, 2019
28156b9
Bump dependencies and add some scripts. (#388)
tomusdrw Feb 13, 2019
6ec3640
Add example for request params (#379)
hskang9 Feb 16, 2019
007a8d4
Use proc_macro_crate to handle import renames (#390)
ascjones Feb 18, 2019
4db3798
Use less restrictive signature for Middleware trait's `next` (#391)
HCastano Feb 22, 2019
d71d3bb
Fix most clippy warnings (#392)
kirushik Feb 25, 2019
d86d7a1
Error on too many params (#394)
ascjones Feb 25, 2019
5bab07d
Fix other clippy warning (#395)
Feb 25, 2019
1296a12
Switch back to upstream ws (#398)
bkchr Feb 27, 2019
ac197bd
ws: replace error-chain with vanilla Error impl (#399)
ascjones Mar 1, 2019
e891334
Update example in IPC README (#400)
kmdouglass Mar 1, 2019
4933feb
Add asynchronous methods to assign_id or reject in pubsub. (#401)
tomusdrw Mar 12, 2019
c24ce48
Delete jsonrpc-macros (superseded by derive) (#409)
ascjones Mar 29, 2019
31ec6d6
Use rustfmt (#407)
dvc94ch Mar 30, 2019
eaa5f24
ws: expose broadcaster (#408)
jacobrosenthal Mar 30, 2019
9360dc8
Implement client support (#405)
dvc94ch Apr 2, 2019
7b797ae
Bump version (11.0) (#413)
ascjones Apr 3, 2019
a1c3bbe
Rename jsonrpc-client to jsonrpc-core-client (#416)
ascjones Apr 3, 2019
0d4f49b
Extract client plumbing from derive, fix circular dependency (#417)
ascjones Apr 5, 2019
1dde12a
Remove derive <-> core-client circular dependency (#419)
ascjones Apr 5, 2019
6fa323d
fix(tcp poll): don't drop when receiver value is ready (#421)
niklasad1 May 6, 2019
893f4e8
Update parking_lot requirement from 0.7 to 0.8 (#428)
dependabot[bot] May 6, 2019
beeaadc
Replace derive compiletests with trybuild (#429)
ascjones May 13, 2019
8c760e3
Client http transport (#420)
ascjones May 21, 2019
ff4e20e
Optional TLS support for HTTP transport (#433) (#435)
abustany May 23, 2019
8c0ada4
Add client transport features (#439)
ascjones May 30, 2019
1bbd403
Add a way to close the http server while waiting (#437)
dvdplm Jun 3, 2019
12b6210
Bump to 12.0 and change core-client transports a bit. (#440)
tomusdrw Jun 4, 2019
3bee17b
Fix ordering, make idempotent. (#441)
tomusdrw Jun 5, 2019
44c501b
Implement subscription support in the client (#436)
dvc94ch Jul 4, 2019
584327b
Bump version (#446)
ascjones Jul 8, 2019
091577f
Strict and non-strict parsing for `core` (#448)
tomusdrw Jul 11, 2019
38f8e91
Introduce IoDelegateExtension. (#447)
tomusdrw Jul 12, 2019
dcaf7e3
Update websocket requirement from 0.22 to 0.23 (#451)
dependabot-preview[bot] Jul 15, 2019
e567d6d
Allow access to raw Params object in jsonrpc-derive (#452)
ebkalderon Jul 16, 2019
c76288c
Update parking_lot requirement from 0.8.0 to 0.9.0 (#450)
dependabot-preview[bot] Jul 16, 2019
0011d4f
Bump to 13.0 (#456)
tomusdrw Jul 18, 2019
2f69657
Remove Notification from Output type. (#462)
tomusdrw Jul 22, 2019
a7b09c0
Add support for notifications in jsonrpc-derive (#454)
ebkalderon Jul 23, 2019
60ac6a1
Add notification to std example in jsonrpc-derive (#464)
ebkalderon Jul 23, 2019
9ec3761
Add an IPC client transport using parity-tokio-ipc (#460)
Xanewok Jul 23, 2019
9cb109c
ipc: Allow specifying different event loop reactor in server builder …
Xanewok Jul 24, 2019
c08393d
Bump parity-tokio-ipc to 0.2 (#465)
Xanewok Jul 24, 2019
97178ce
[core-client] add websockets connect method accepting valid Url (#468)
ascjones Aug 5, 2019
3e7ae2f
Update ws requirement from 0.8 to 0.9 (#472)
dependabot-preview[bot] Aug 5, 2019
5b07faa
Add a method to handle empty response. (#473)
tomusdrw Aug 6, 2019
54c4de5
[client] don't block other subscriptions if subscriber not ready (#479)
ascjones Aug 19, 2019
f5f91bd
Make IoHandlers cloneable. (#483)
tomusdrw Aug 26, 2019
38043dd
Implement client notification support (#486)
ebkalderon Sep 4, 2019
97b08da
Add `iter` and `IntoIterator` to `IoHandler` (#488)
tomusdrw Sep 13, 2019
77d7fb6
fix for #490, related to NikVolf/parity-tokio-ipc#15 (#491)
onsails Sep 30, 2019
d8cfec5
Run format only on stable @ linux. (#494)
tomusdrw Sep 30, 2019
3b790c6
Fix threading and closing of servers (#495)
tomusdrw Oct 7, 2019
7b94363
Bump to 14.0 (#496)
tomusdrw Oct 9, 2019
cc8f26d
Solve compiler error when serde is not a dependency of user project (…
simeir4 Oct 10, 2019
4418476
Make sure RpcEventLoop is Send+Sync (#499)
tomusdrw Oct 10, 2019
d3d8c6b
ignore dropped connections (#502)
seunlanlege Oct 16, 2019
1f11075
Integrate gitlab ci (#503)
fevo1971 Oct 16, 2019
8ebb62d
Disable travis & appveyor. (#506)
tomusdrw Oct 16, 2019
d1993a8
Fix race condition on `wait()` (#504)
foriequal0 Oct 16, 2019
3fc22d1
Update syn & co (#507)
tomusdrw Oct 18, 2019
b4635c5
Bump version. (#509)
tomusdrw Oct 18, 2019
163af8c
Multiple methods to initiate same subscriptions (#512)
NikVolf Oct 24, 2019
a22e0db
Version bump. (#513)
tomusdrw Oct 24, 2019
2135c25
Avoid closing HTTP server on connection error (#515)
tomusdrw Oct 25, 2019
2d38e64
Update env_logger requirement from 0.6 to 0.7 (#493)
dependabot-preview[bot] Oct 27, 2019
8912104
Update websocket requirement from 0.23 to 0.24 (#516)
dependabot-preview[bot] Nov 11, 2019
1d351d3
upgrade parity-tokio-ipc (#519)
Nov 19, 2019
591e916
workaround serde deserializing incorrectly when arbitrary_precision e…
insipx Nov 22, 2019
d661b0c
Avoid using buffer_unordered (#518)
tomusdrw Nov 26, 2019
b6e7521
Bump version. (#522)
tomusdrw Nov 26, 2019
d2e0bb7
Fix basic example from on the readme file (#523)
rutaihwa Nov 27, 2019
23e6097
14.0.5 bump (#524)
tomusdrw Nov 28, 2019
a427b62
Bump parity-tokio-ipc (#525)
seunlanlege Dec 4, 2019
a2a6929
Fix automate script. (#526)
tomusdrw Dec 4, 2019
6bddbc7
New automate script. (#527)
tomusdrw Dec 5, 2019
3bfb894
remove no longer needed externs (#529)
NikVolf Dec 21, 2019
2c26aad
[client] notify subscriber if subscription was rejected (#530)
ascjones Jan 7, 2020
596ed3a
fix warning (#533)
NikVolf Jan 16, 2020
2048538
IoHandlerExtension for Option (#535)
tomusdrw Jan 28, 2020
c20705c
Fix checkstyle for rustc 1.41.0 (#537)
jstarry Jan 31, 2020
93e4773
Fix ServerBuilder::cors_max_age doc comment time unit (#536)
jstarry Feb 1, 2020
a1f57ae
Fix a broken import in stdio example (#538)
sean0x42 Feb 4, 2020
ef44a62
bump parking_lot and patch versions (#539)
Feb 7, 2020
4a6c499
Wait for http server to close on Drop. (#543)
tomusdrw Feb 20, 2020
84f2c42
Add "Accept:application/json" header for all requests. (#544)
yinhu-prismalab Feb 23, 2020
c64a48a
Client call with named params (#541)
willemolding Mar 23, 2020
06375c3
14.1.0 bump (#545)
ascjones Apr 14, 2020
eed011e
Wait for published version to be available (#546)
ascjones Apr 14, 2020
5f1e693
Fix mac builds. (#550)
tomusdrw May 22, 2020
0d31c50
hosts: when binding to unspecified address allow requests from localh…
andresilva May 22, 2020
1779dbe
Add a subscription manager (#548)
HCastano May 27, 2020
e2569b9
Place NumericIdProvider's Id behind an Arc (#554)
HCastano Jun 2, 2020
ef92a48
Use matches! macro (#553)
HCastano Jun 2, 2020
e4548ba
Bump version. (#556)
tomusdrw Jun 3, 2020
a615225
Bump quote crate version (#558)
HCastano Jun 3, 2020
bf8c33c
Bump `derive` version to v14.2.1 (#559)
HCastano Jun 3, 2020
dfa6b98
change (ci): some optimizations; new image (#560)
TriplEight Jun 10, 2020
c056be4
Allow skipping and retrying publishing. (#557)
tomusdrw Jul 22, 2020
57575ef
Add missing user specified trait bounds in [rpc] macro (#569)
liuchengxu Jul 27, 2020
99bd064
Migrate core to futures=0.3 (#565)
tomusdrw Jul 28, 2020
254b630
Update readme. (#568)
tomusdrw Jul 28, 2020
8e7ddc9
Make sure manager is Sync+Send (#573)
tomusdrw Jul 30, 2020
b165fac
Remove failure dependency. (#579)
tomusdrw Aug 28, 2020
92e3c14
Use patched ws-rs (#584)
maciejhirsz Sep 18, 2020
7a4bf1e
Fix publishing script. (#593)
tomusdrw Sep 30, 2020
07a002a
update parking_lot to v0.11 (#591)
koushiro Sep 30, 2020
2cb9752
Expose direct configuration of max in and out buffer capacity (#594)
emostov Oct 5, 2020
454cf5d
Update examples in top-level readme. (#588)
tomusdrw Nov 6, 2020
40eec20
Fix typos (#587)
nazar-pc Dec 9, 2020
61ea7c6
[forwardport] Update `local` client to support middleware (Kudos Seun…
tomusdrw Dec 9, 2020
91cf903
Migrate to Tokio 0.2 (#603)
Xanewok Jan 11, 2021
f418030
Bump version. (#608)
tomusdrw Jan 20, 2021
5d6ba66
fix typo in select_with_weak future (#610)
nanne007 Jan 27, 2021
9d4b261
Bump bugfix release of IPC. (#613)
tomusdrw Jan 29, 2021
9c8110d
core: Allow for using only futures-util dependency (#609)
Xanewok Mar 8, 2021
135d929
Fix link to documentation (#620)
taiki-e Mar 16, 2021
014b1ec
Return error when unsubscribing from invalid subscription id (#619)
jstarry Mar 31, 2021
609d7a6
Bump minor version. (#624)
tomusdrw Apr 1, 2021
ac72c85
Update to Tokio 1.0 (#628)
Xanewok Jul 7, 2021
68511bc
Add clippy to CI and fix several clippy warnings (#625)
chevdor Jul 8, 2021
ab30170
Update to `parity-ws` 0.11 (#630)
koute Jul 20, 2021
dc6b8ed
Bump versions to v18 (#629)
Xanewok Jul 20, 2021
4e11901
wip: http transport: Optionally allow gzip responses
ckamm Oct 21, 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
10 changes: 9 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ trim_trailing_whitespace=true
max_line_length=120
insert_final_newline=true

[.travis.yml]
[{.travis.yml,appveyor.yml}]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf

[*.stderr]
indent_style=none
indent_size=none
end_of_line=none
charset=none
trim_trailing_whitespace=none
insert_final_newline=none
65 changes: 65 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
stages:
- checkstyle
- test
variables: &default-vars
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0

.test_and_build: &test_and_build
script:
- cargo build --all
- cargo test --all

.only: &only
only:
- triggers
- tags
- master
- schedules
- web
- /^[0-9]+$/

.docker-env: &docker-env
image: paritytech/ci-linux:production
before_script:
- rustup show
- cargo --version
- sccache -s
variables:
<<: *default-vars
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- linux-docker

# check style
checkstyle-linux-stable:
stage: checkstyle
<<: *only
<<: *docker-env
script:
- rustup component add rustfmt clippy
- cargo fmt --all -- --check
- cargo clippy
allow_failure: true

# test rust stable
test-linux-stable:
stage: test
<<: *docker-env
<<: *only
<<: *test_and_build

test-mac-stable:
stage: test
<<: *test_and_build
<<: *only
tags:
- osx
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[workspace]
members = [
"core",
"core-client",
"core-client/transports",
"http",
"ipc",
"macros",
"minihttp",
"derive",
"pubsub",
"pubsub/more-examples",
"server-utils",
Expand Down
117 changes: 83 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,38 @@
Rust implementation of JSON-RPC 2.0 Specification.
Transport-agnostic `core` and transport servers for `http`, `ipc`, `websockets` and `tcp`.

[![Build Status][travis-image]][travis-url]
**New!** Support for [clients](#Client-support).

[travis-image]: https://travis-ci.org/paritytech/jsonrpc.svg?branch=master
[travis-url]: https://travis-ci.org/paritytech/jsonrpc

[Documentation](http://paritytech.github.io/jsonrpc/)
[Documentation](https://docs.rs/jsonrpc-core/)

## Sub-projects
- [jsonrpc-core](./core) [![crates.io][core-image]][core-url]
- [jsonrpc-core-client](./core-client) [![crates.io][core-client-image]][core-client-url]
- [jsonrpc-http-server](./http) [![crates.io][http-server-image]][http-server-url]
- [jsonrpc-minihttp-server](./minihttp)
- [jsonrpc-ipc-server](./ipc)
- [jsonrpc-ipc-server](./ipc) [![crates.io][ipc-server-image]][ipc-server-url]
- [jsonrpc-tcp-server](./tcp) [![crates.io][tcp-server-image]][tcp-server-url]
- [jsonrpc-ws-server](./ws)
- [jsonrpc-stdio-server](./stdio)
- [jsonrpc-macros](./macros) [![crates.io][macros-image]][macros-url]
- [jsonrpc-ws-server](./ws) [![crates.io][ws-server-image]][ws-server-url]
- [jsonrpc-stdio-server](./stdio) [![crates.io][stdio-server-image]][stdio-server-url]
- [jsonrpc-derive](./derive) [![crates.io][derive-image]][derive-url]
- [jsonrpc-server-utils](./server-utils) [![crates.io][server-utils-image]][server-utils-url]
- [jsonrpc-pubsub](./pubsub) [![crates.io][pubsub-image]][pubsub-url]

[core-image]: https://img.shields.io/crates/v/jsonrpc-core.svg
[core-url]: https://crates.io/crates/jsonrpc-core
[core-client-image]: https://img.shields.io/crates/v/jsonrpc-core-client.svg
[core-client-url]: https://crates.io/crates/jsonrpc-core-client
[http-server-image]: https://img.shields.io/crates/v/jsonrpc-http-server.svg
[http-server-url]: https://crates.io/crates/jsonrpc-http-server
[ipc-server-image]: https://img.shields.io/crates/v/jsonrpc-ipc-server.svg
[ipc-server-url]: https://crates.io/crates/jsonrpc-ipc-server
[tcp-server-image]: https://img.shields.io/crates/v/jsonrpc-tcp-server.svg
[tcp-server-url]: https://crates.io/crates/jsonrpc-tcp-server
[macros-image]: https://img.shields.io/crates/v/jsonrpc-macros.svg
[macros-url]: https://crates.io/crates/jsonrpc-macros
[ws-server-image]: https://img.shields.io/crates/v/jsonrpc-ws-server.svg
[ws-server-url]: https://crates.io/crates/jsonrpc-ws-server
[stdio-server-image]: https://img.shields.io/crates/v/jsonrpc-stdio-server.svg
[stdio-server-url]: https://crates.io/crates/jsonrpc-stdio-server
[derive-image]: https://img.shields.io/crates/v/jsonrpc-derive.svg
[derive-url]: https://crates.io/crates/jsonrpc-derive
[server-utils-image]: https://img.shields.io/crates/v/jsonrpc-server-utils.svg
[server-utils-url]: https://crates.io/crates/jsonrpc-server-utils
[pubsub-image]: https://img.shields.io/crates/v/jsonrpc-pubsub.svg
Expand All @@ -38,48 +43,41 @@ Transport-agnostic `core` and transport servers for `http`, `ipc`, `websockets`
## Examples

- [core](./core/examples)
- [macros](./macros/examples)
- [derive](./derive/examples)
- [pubsub](./pubsub/examples)

### Basic Usage (with HTTP transport)

```rust
extern crate jsonrpc_core;
extern crate jsonrpc_minihttp_server;

use jsonrpc_core::{IoHandler, Value, Params};
use jsonrpc_minihttp_server::{ServerBuilder};
use jsonrpc_http_server::jsonrpc_core::{IoHandler, Value, Params};
use jsonrpc_http_server::ServerBuilder;

fn main() {
let mut io = IoHandler::new();
io.add_method("say_hello", |_params: Params| {
Ok(Value::String("hello".to_string()))
let mut io = IoHandler::default();
io.add_method("say_hello", |_params: Params| async {
Ok(Value::String("hello".to_owned()))
});

let server = ServerBuilder::new(io)
.threads(3)
.start_http(&"127.0.0.1:3030".parse().unwrap())
.unwrap();

server.wait().unwrap();
server.wait();
}
```

### Basic usage with macros
### Basic usage with derive

```rust
extern crate jsonrpc_core;
#[macro_use]
extern crate jsonrpc_macros;

use jsonrpc_core::Result;
use jsonrpc_derive::rpc;

build_rpc_trait! {
pub trait Rpc {
/// Adds two numbers and returns a result
#[rpc(name = "add")]
fn add(&self, u64, u64) -> Result<u64>;
}
#[rpc]
pub trait Rpc {
/// Adds two numbers and returns a result
#[rpc(name = "add")]
fn add(&self, u64, u64) -> Result<u64>;
}

pub struct RpcImpl;
Expand All @@ -89,8 +87,59 @@ impl Rpc for RpcImpl {
}
}


fn main() {
let mut io = jsonrpc_core::IoHandler::new();
io.extend_with(RpcImpl.to_delegate())
}
```

### Client support

```rust
use jsonrpc_core_client::transports::local;
use jsonrpc_core::{Error, IoHandler, Result};
use jsonrpc_derive::rpc;

/// Rpc trait
#[rpc]
pub trait Rpc {
/// Returns a protocol version
#[rpc(name = "protocolVersion")]
fn protocol_version(&self) -> Result<String>;

/// Adds two numbers and returns a result
#[rpc(name = "add", alias("callAsyncMetaAlias"))]
fn add(&self, a: u64, b: u64) -> Result<u64>;

/// Performs asynchronous operation
#[rpc(name = "callAsync")]
fn call(&self, a: u64) -> FutureResult<String, Error>;
}

struct RpcImpl;

impl Rpc for RpcImpl {
fn protocol_version(&self) -> Result<String> {
Ok("version1".into())
}

fn add(&self, a: u64, b: u64) -> Result<u64> {
Ok(a + b)
}

fn call(&self, _: u64) -> FutureResult<String, Error> {
future::ok("OK".to_owned())
}
}

fn main() {
let mut io = IoHandler::new();
io.extend_with(RpcImpl.to_delegate());

let fut = {
let (client, server) = local::connect::<gen_client::Client, _, _>(io);
client.add(5, 6).map(|res| println!("5 + 6 = {}", res)).join(server)
};
fut.wait().unwrap();
}
```
21 changes: 21 additions & 0 deletions _automate/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -xeu

VERSION=$1
PREV_DEPS=$2
NEW_DEPS=$3

ack "^version = \"" -l | \
grep toml | \
xargs sed -i "s/^version = \".*/version = \"$VERSION\"/"

ack "{ version = \"$PREV_DEPS" -l | \
grep toml | \
xargs sed -i "s/{ version = \"$PREV_DEPS/{ version = \"$NEW_DEPS/"

ack " = \"$PREV_DEPS" -l | \
grep md | \
xargs sed -i "s/ = \"$PREV_DEPS/ = \"$NEW_DEPS/"

cargo check
Loading