Skip to content

Commit

Permalink
Merge branch 'master' into dp-all-requests-timeout
Browse files Browse the repository at this point in the history
* master: (21 commits)
  New proc macro (#387)
  Streaming RpcParams parsing (#401)
  Set allowed Host header values (#399)
  Synchronization-less async connections in ws-server (#388)
  [ws server]: terminate already established connection(s) when the server is stopped (#396)
  feat: customizable JSON-RPC error codes via new enum variant on `CallErrror` (#394)
  [ci]: test each individual crate's manifest (#392)
  Add a way to stop servers (#386)
  [jsonrpsee types]: unify a couple of types + more tests (#389)
  Update roadmap link in readme (#390)
  Cross-origin protection (#375)
  Method aliases + RpcModule: Clone (#383)
  Use criterion's async bencher (#385)
  Async/subscription benches (#372)
  send text (#374)
  Fix link to ws server in README.md (#373)
  Concat -> simple push (#370)
  Add missing `rt` feature (#369)
  Release prep for v0.2 (#368)
  chore(scripts): publish script (#354)
  ...
  • Loading branch information
dvdplm committed Jul 6, 2021
2 parents c9d1881 + ddb5080 commit 1085a02
Show file tree
Hide file tree
Showing 80 changed files with 3,060 additions and 534 deletions.
132 changes: 124 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
override: true
components: clippy, rustfmt

- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo fmt
uses: actions-rs/cargo@v1.0.3
Expand Down Expand Up @@ -59,10 +59,10 @@ jobs:
toolchain: stable
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo check all targets
- name: Cargo check all targets (use Cargo.toml in workspace)
uses: actions-rs/cargo@v1.0.3
with:
command: check
Expand All @@ -74,8 +74,68 @@ jobs:
command: check
args: --manifest-path http-client/Cargo.toml --no-default-features --features tokio02

- name: Cargo check HTTP client
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path http-client/Cargo.toml

- name: Cargo check HTTP server
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path http-server/Cargo.toml

- name: Cargo check WS client
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path ws-client/Cargo.toml

- name: Cargo check WS client with tokio02
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path ws-client/Cargo.toml --no-default-features --features tokio02

- name: Cargo check WS server
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path ws-server/Cargo.toml

- name: Cargo check types
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path types/Cargo.toml

- name: Cargo check utils
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path utils/Cargo.toml

- name: Cargo check proc macros
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path proc-macros/Cargo.toml

- name: Cargo check test utils
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path test-utils/Cargo.toml

- name: Cargo check examples
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path examples/Cargo.toml

tests:
name: Run tests
name: Run tests Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -88,8 +148,64 @@ jobs:
toolchain: stable
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --workspace

- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test

tests_macos:
name: Run tests macos
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2.3.4

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1.0.7
with:
profile: minimal
toolchain: stable
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --workspace

- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test

tests_windows:
name: Run tests Windows
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2.3.4

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1.0.7
with:
profile: minimal
toolchain: stable
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo build
uses: actions-rs/cargo@v1.0.3
Expand Down
96 changes: 96 additions & 0 deletions .scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
#
# This script is copied from `https://github.com/paritytech/jsonrpc` with some minor tweaks.

set -eu

ORDER=(types proc-macros utils http-client http-server ws-client ws-server jsonrpsee)

function read_toml () {
NAME=""
VERSION=""
NAME=$(grep "^name" ./Cargo.toml | sed -e 's/.*"\(.*\)"/\1/')
VERSION=$(grep "^version" ./Cargo.toml | sed -e 's/.*"\(.*\)"/\1/')
}
function remote_version () {
REMOTE_VERSION=""
REMOTE_VERSION=$(cargo search "$NAME" | grep "^$NAME =" | sed -e 's/.*"\(.*\)".*/\1/')
}

# First display the plan
for CRATE_DIR in ${ORDER[@]}; do
cd $CRATE_DIR > /dev/null
read_toml
echo "$NAME@$VERSION"
cd - > /dev/null
done

read -p ">>>> Really publish?. Press [enter] to continue. "

set -x

cargo clean

set +x

# Then actually perform publishing.
for CRATE_DIR in ${ORDER[@]}; do
cd $CRATE_DIR > /dev/null
read_toml
remote_version
# Seems the latest version matches, skip by default.
if [ "$REMOTE_VERSION" = "$VERSION" ] || [[ "$REMOTE_VERSION" > "$VERSION" ]]; then
RET=""
echo "Seems like $NAME@$REMOTE_VERSION is already published. Continuing in 5s. "
read -t 5 -p ">>>> Type [r][enter] to retry, or [enter] to continue... " RET || true
if [ "$RET" != "r" ]; then
echo "Skipping $NAME@$VERSION"
cd - > /dev/null
continue
fi
fi

# Attempt to publish (allow retries)
while : ; do
# give the user an opportunity to abort or skip before publishing
echo "🚀 Publishing $NAME@$VERSION..."
sleep 3

set +e && set -x
cargo publish $@
RES=$?
set +x && set -e
# Check if it succeeded
if [ "$RES" != "0" ]; then
CHOICE=""
echo "##### Publishing $NAME failed"
read -p ">>>>> Type [s][enter] to skip, or [enter] to retry.. " CHOICE
if [ "$CHOICE" = "s" ]; then
break
fi
else
break
fi
done

# Wait again to make sure that the new version is published and available.
echo "Waiting for $NAME@$VERSION to become available at the registry..."
while : ; do
sleep 3
remote_version
if [ "$REMOTE_VERSION" = "$VERSION" ]; then
echo "🥳 $NAME@$VERSION published succesfully."
sleep 3
break
else
echo "#### Got $NAME@$REMOTE_VERSION but expected $NAME@$VERSION. Retrying..."
fi
done
cd - > /dev/null
done

echo "Tagging jsonrpsee@$VERSION"
set -x
git tag -a v$VERSION -m "Version $VERSION"
sleep 3
git push --tags
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,23 @@ The format is based on [Keep a Changelog].
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.2.0] – 2021-06-04

[changed] The crate structure changed to several smaller crates, enabling users to pick and choose. The `jsonrpsee` crate works as a façade crate for users to pick&chose what components they wish to use.

[changed] Starting with this release, the project is assuming `tokio` is the async executor.

[changed] Revamped RPC subscription/method definition: users now provide closures when initializing the server and it is no longer possible to register new methods after the server started.

[changed] Refactored the internals from the ground up.

[added] Support for async methods

[added] Support for batch requests (http/ws)

[changed] the proc macros are currently limited to client side.

[added] crate publication script

## [v0.1.0] - 2020-02-28
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Support `WebSocket` and `HTTP` transports for both client and server.
The library is still under development; do not use in production.

## Sub-projects
- [jsonrpsee-http-client](./http-client) [![crates.io][ws-client-image]][ws-client-url]
- [jsonrpsee-http-client](./http-client) [![crates.io][http-client-image]][http-client-url]
- [jsonrpsee-http-server](./http-server) [![crates.io][http-server-image]][http-server-url]
- [jsonrpsee-proc-macros](./proc-macros) [![crates.io][proc-macros-image]][proc-macros-url]
- [jsonrpsee-ws-client](./ws-client) [![crates.io][ws-client-image]][ws-client-url]
- [jsonrpsee-ws-server](./http-server) [![crates.io][http-server-image]][http-server-url]
- [jsonrpsee-ws-server](./http-server) [![crates.io][ws-server-image]][ws-server-url]

[http-client-image]: https://img.shields.io/crates/v/jsonrpsee-http-client.svg
[http-client-url]: https://crates.io/crates/jsonrpsee-http-client
Expand All @@ -37,7 +37,7 @@ The library is still under development; do not use in production.

## Roadmap

See [tracking issue for next stable release](https://github.com/paritytech/jsonrpsee/issues/251)
See [tracking issue for next stable release (0.3)](https://github.com/paritytech/jsonrpsee/issues/376)

## Users

Expand Down
5 changes: 3 additions & 2 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ license = "MIT"
publish = false

[dev-dependencies]
criterion = "0.3"
futures-channel = "0.3.14"
criterion = { version = "0.3", features = ["async_tokio", "html_reports"] }
futures-channel = "0.3.15"
futures-util = "0.3.15"
jsonrpsee = { path = "../jsonrpsee", features = ["full"] }
num_cpus = "1"
serde_json = "1"
Expand Down
Loading

0 comments on commit 1085a02

Please sign in to comment.