-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore release v0.17 #1083
Merged
Merged
chore release v0.17 #1083
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ada9895
update version number
niklasad1 8f19479
update changelog
niklasad1 a865b01
Update CHANGELOG.md
niklasad1 310ddd4
Update CHANGELOG.md
niklasad1 9eda01a
fix nits
niklasad1 fddfbfb
Merge remote-tracking branch 'origin/chore-release-v0.17' into chore-…
niklasad1 0636ce7
more nits
niklasad1 f757f59
Update CHANGELOG.md
niklasad1 27a33cf
update changelog again
niklasad1 10d8fbe
Update CHANGELOG.md
niklasad1 d154253
Update CHANGELOG.md
niklasad1 725b328
address grumbles
niklasad1 430b69e
add more examples for pipe_from_stream
niklasad1 f2301b6
update CHANGELOG
niklasad1 408888f
update CHANGELOG
niklasad1 e24d613
Update CHANGELOG.md
niklasad1 e5dc314
Update CHANGELOG.md
niklasad1 fd3b0a9
Update CHANGELOG.md
niklasad1 44ee0b3
update CHANGELOG
niklasad1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -4,6 +4,151 @@ The format is based on [Keep a Changelog]. | |
|
||
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ | ||
|
||
## [v0.17.0] - 2023-04-14 | ||
|
||
This is a significant release and the major breaking changes to be aware of are: | ||
|
||
### Server backpressure | ||
|
||
This release changes the server to be "backpressured" and it mostly concerns subscriptions. | ||
New APIs has been introduced because that and the API `pipe_from_stream` has been removed. | ||
niklasad1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Before it was possible to do: | ||
|
||
```rust | ||
module | ||
.register_subscription("sub", "s", "unsub", |_, sink, _| async move { | ||
let stream = stream_of_integers(); | ||
|
||
tokio::spawn(async move { | ||
sink.pipe_from_stream(stream) | ||
}); | ||
}) | ||
.unwrap(); | ||
``` | ||
|
||
After this release one must do something like: | ||
|
||
```rust | ||
module | ||
.register_subscription("sub", "s", "unsub", |_, pending, _| async move { | ||
pending.accept().await?; | ||
|
||
let stream = stream_of_integers(); | ||
|
||
loop { | ||
tokio::select! { | ||
_ = sink.closed() => break Ok(()), | ||
maybe_item = stream.next() => { | ||
let Some(item) = maybe_item else { | ||
break Ok(()) | ||
}; | ||
let msg = SubscriptionMessage::from_json(&item)?; | ||
if let Err(e) = sink.send_timeout(msg) { | ||
match e { | ||
// The subscription is closed. | ||
Err(TrySendError::Closed(_)) => break Ok(()), | ||
// Channel is full, just drop the subscription | ||
Err(TrySendError::Full(_)) => break Ok(()), | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
.unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe worth just pointing to some example where we've used this (I think we used it in a few places) too because they also show that one can write some helper function to do it if needed in multiple places :) |
||
``` | ||
|
||
### Method call return type is more flexible | ||
|
||
This release also introduces a trait called `IntoResponse` which is makes it possible to return custom types and/or error | ||
types instead of enforcing everything to return `Result<T, jsonrpsee::core::Error>` | ||
|
||
This affects the APIs `RpcModule::register_method`, `RpcModule::register_async_method` and `RpcModule::register_blocking_method` | ||
and when these are used in the proc macro API are affected by this change. | ||
Be aware that [the client APIs don't support this yet](https://github.com/paritytech/jsonrpsee/issues/1067) | ||
|
||
The `IntoResponse` trait is already implemented for `Result<T, jsonrpsee::core::Error>` and for the primitive types | ||
|
||
Before it was possible to do: | ||
|
||
```rust | ||
// This would return Result<&str, jsonrpsee::core::Error> | ||
module.register_method("say_hello", |_, _| Ok("lo"))?; | ||
``` | ||
|
||
After this release it possible to do: | ||
niklasad1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```rust | ||
// Note, this method call is infallible and you might not want to return Result. | ||
module.register_method("say_hello", |_, _| "lo")?; | ||
``` | ||
|
||
### Subscription API is changed. | ||
|
||
jsonrpsee now spawns the subscriptions via `tokio::spawn` and it's sufficient to provide an async block in `register_subscription` | ||
|
||
Further, the subscription API had an explicit close API for closing subscriptions which was hard to understand and | ||
to get right. This has been removed and everything is handled by the return value/type of the async block instead. | ||
|
||
Example: | ||
|
||
```rust | ||
module | ||
.register_subscription::<RpcResult<(), _, _>::("sub", "s", "unsub", |_, pending, _| async move { | ||
// This just answers the RPC call and if this fails => no close notification is sent out. | ||
pending.accept().await?; | ||
// This is sent out as a `close notification/message`. | ||
Err(anyhow::anyhow!("The subscription failed"))?; | ||
}) | ||
.unwrap(); | ||
``` | ||
|
||
The return value in example above needs to implement `IntoSubscriptionCloseResponse` and in this case it's `Result<(), E>` which | ||
niklasad1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implies that any value after `pending.accept().await?`. | ||
niklasad1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Because `Result<(), E>` is used here then close notification will sent out as error notification and it's also possible | ||
to ignore the return value by using `()` or implement `IntoSubscriptionCloseResponse` for some other behaviour. | ||
niklasad1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### [Added] | ||
- feat(server): configurable limit for batch requests. ([#1073](https://github.com/paritytech/jsonrpsee/pull/1073)) | ||
- feat(http client): add tower middleware ([#981](https://github.com/paritytech/jsonrpsee/pull/981)) | ||
|
||
### [Fixed] | ||
- add tests for ErrorObject ([#1078](https://github.com/paritytech/jsonrpsee/pull/1078)) | ||
- fix: tokio v1.27 ([#1062](https://github.com/paritytech/jsonrpsee/pull/1062)) | ||
- fix: remove needless `Semaphore::(u32::MAX)` ([#1051](https://github.com/paritytech/jsonrpsee/pull/1051)) | ||
- fix server: don't send error on JSON-RPC notifications ([#1021](https://github.com/paritytech/jsonrpsee/pull/1021)) | ||
- fix: add `max_log_length` APIs and use missing configs ([#956](https://github.com/paritytech/jsonrpsee/pull/956)) | ||
- fix(rpc module): subscription close bug ([#1011](https://github.com/paritytech/jsonrpsee/pull/1011)) | ||
- fix: customized server error codes ([#1004](https://github.com/paritytech/jsonrpsee/pull/1004)) | ||
|
||
### [Changed] | ||
- docs: introduce workspace attributes and add keywords ([#1077](https://github.com/paritytech/jsonrpsee/pull/1077)) | ||
- refactor(server): downgrade connection log ([#1076](https://github.com/paritytech/jsonrpsee/pull/1076)) | ||
- chore(deps): update webpki-roots and tls ([#1068](https://github.com/paritytech/jsonrpsee/pull/1068)) | ||
- rpc module: refactor subscriptions to return `impl IntoSubscriptionResponse` ([#1034](https://github.com/paritytech/jsonrpsee/pull/1034)) | ||
- add `IntoResponse` trait for method calls ([#1057](https://github.com/paritytech/jsonrpsee/pull/1057)) | ||
- Make `jsonrpc` protocol version field in `Response` as `Option` ([#1046](https://github.com/paritytech/jsonrpsee/pull/1046)) | ||
- server: remove dependency http ([#1037](https://github.com/paritytech/jsonrpsee/pull/1037)) | ||
- chore(deps): update tower-http requirement from 0.3.4 to 0.4.0 ([#1033](https://github.com/paritytech/jsonrpsee/pull/1033)) | ||
- chore(deps): update socket2 requirement from 0.4.7 to 0.5.1 ([#1032](https://github.com/paritytech/jsonrpsee/pull/1032)) | ||
- Update bound type name ([#1029](https://github.com/paritytech/jsonrpsee/pull/1029)) | ||
- rpc module: remove `SubscriptionAnswer` ([#1025](https://github.com/paritytech/jsonrpsee/pull/1025)) | ||
- make verify_and_insert pub ([#1028](https://github.com/paritytech/jsonrpsee/pull/1028)) | ||
- update MethodKind ([#1026](https://github.com/paritytech/jsonrpsee/pull/1026)) | ||
- remove batch response ([#1020](https://github.com/paritytech/jsonrpsee/pull/1020)) | ||
- remove debug log ([#1024](https://github.com/paritytech/jsonrpsee/pull/1024)) | ||
- client: rename `max_notifs_per_subscription` to `max_buffer_capacity_per_subscription` ([#1012](https://github.com/paritytech/jsonrpsee/pull/1012)) | ||
- client: feature gate tls cert store ([#994](https://github.com/paritytech/jsonrpsee/pull/994)) | ||
- server: bounded channels and backpressure ([#962](https://github.com/paritytech/jsonrpsee/pull/962)) | ||
- client: use tokio channels ([#999](https://github.com/paritytech/jsonrpsee/pull/999)) | ||
- chore: update gloo-net ^0.2.6 ([#978](https://github.com/paritytech/jsonrpsee/pull/978)) | ||
- Custom errors ([#977](https://github.com/paritytech/jsonrpsee/pull/977)) | ||
- client: distinct APIs to configure max request and response sizes ([#967](https://github.com/paritytech/jsonrpsee/pull/967)) | ||
- server: replace `FutureDriver` with `tokio::spawn` ([#1080](https://github.com/paritytech/jsonrpsee/pull/1080)) | ||
- server: uniform whitespace handling in rpc calls ([#1082](https://github.com/paritytech/jsonrpsee/pull/1082)) | ||
|
||
## [v0.16.2] - 2022-12-01 | ||
|
||
This release adds `Clone` and `Copy` implementations. | ||
|
@@ -38,7 +183,7 @@ Both HTTP and WebSocket are still enabled by default. | |
|
||
v0.16.0 is a breaking release and the major changes are: | ||
|
||
- The server now support WS and HTTP on the same socket and the `jsonrpsee-http-server` and `jsonrpsee-ws-server` crates are moved to the `jsonrpsee-server` crate instead. | ||
- The server now support WS and HTTP on the same socket and the `jsonrpsee-http-server` and `jsonrpsee-ws-server` crates are moved to the `jsonrpsee-server` crate instead. | ||
- The client batch request API is improved such as the errors and valid responses can be iterated over. | ||
- The server has `tower middleware` support. | ||
- The server now adds a tracing span for each connection to distinguish logs per connection. | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing release! Nice work! 🚀