-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from niklasad1/na-impl-subxt-rpc-client
feat: implement subxt rpc client trait
- Loading branch information
Showing
6 changed files
with
333 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "cargo" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Continuous integration | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
paths-ignore: | ||
- 'README.md' | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
check-style: | ||
name: Check style | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v4.1.1 | ||
|
||
- name: Install Rust stable toolchain | ||
uses: actions-rs/toolchain@v1.0.7 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
components: clippy, rustfmt | ||
|
||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2.7.1 | ||
|
||
- name: Cargo fmt | ||
uses: actions-rs/cargo@v1.0.3 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
|
||
- name: Check clippy | ||
uses: actions-rs/clippy-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: --all-features | ||
|
||
check-docs: | ||
name: Check rustdoc | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v4.1.1 | ||
|
||
- name: Install Rust nightly toolchain | ||
uses: actions-rs/toolchain@v1.0.7 | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
override: true | ||
|
||
- name: Check rustdoc | ||
run: RUSTDOCFLAGS="--cfg docsrs --deny rustdoc::broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items --all-features | ||
|
||
check-code: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v4.1.1 | ||
|
||
- name: Install Rust stable toolchain | ||
uses: actions-rs/toolchain@v1.0.7 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Install cargo-hack | ||
uses: baptiste0928/cargo-install@v2 | ||
with: | ||
crate: cargo-hack | ||
version: 0.5 | ||
|
||
- name: Install cargo-machete | ||
uses: baptiste0928/cargo-install@v2 | ||
with: | ||
crate: cargo-machete | ||
version: 0.5 | ||
|
||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2.7.1 | ||
|
||
- name: Cargo check all targets and features | ||
run: cargo hack check --workspace --each-feature --all-targets | ||
|
||
- name: Check unused dependencies | ||
run: cargo machete | ||
|
||
tests_ubuntu: | ||
name: Run tests Ubuntu | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- 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@v2.7.1 | ||
|
||
- name: Cargo test | ||
uses: actions-rs/cargo@v1.0.3 | ||
with: | ||
command: test | ||
args: --workspace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# reconnecting-jsonrpsee-ws-client | ||
|
||
Wrapper crate over the jsonrpsee ws client which automatically reconnects under the hood | ||
without that the user has to restart it manually by re-transmitting pending calls | ||
and re-establish subscriptions that where closed when the connection was terminated. | ||
|
||
This is crate is temporary fix for subxt because it's not easy to implement | ||
reconnect-logic on-top it at the moment. | ||
|
||
The tricky part is subscription which may loose a few notifications then re-connecting | ||
where it's not possible to know which ones. | ||
Lost subscription notifications may be very important to know in some scenarios then | ||
this crate is not recommended. | ||
|
||
## Example | ||
|
||
```rust | ||
let client = ReconnectingWsClient::new( | ||
"ws://example.com", | ||
ExponentialBackoff::from_millis(10), | ||
PingConfig::Enabled(Duration::from_secs(6)) | ||
).await.unwrap(); | ||
let mut sub = client.subscribe("subscribe_lo".to_string(), rpc_params![], "unsubscribe_lo".to_string()).await.unwrap(); | ||
let msg = sub.recv().await.unwrap(); | ||
``` |
Oops, something went wrong.