Skip to content

chore: release v0.25 #1566

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

Merged
merged 5 commits into from
Apr 24, 2025
Merged

chore: release v0.25 #1566

merged 5 commits into from
Apr 24, 2025

Conversation

niklasad1
Copy link
Contributor

@niklasad1 niklasad1 commented Apr 23, 2025

## [v0.25.0] - 2025-04-24

A new breaking release which has been in the making for a while and the biggest change is that the
`RpcServiceT trait` has been changed to support both the client and server side:

```rust
pub trait RpcServiceT {
	/// Response type for `RpcServiceT::call`.
	type MethodResponse;
	/// Response type for `RpcServiceT::notification`.
	type NotificationResponse;
	/// Response type for `RpcServiceT::batch`.
	type BatchResponse;

	/// Processes a single JSON-RPC call, which may be a subscription or regular call.
	fn call<'a>(&self, request: Request<'a>) -> impl Future<Output = Self::MethodResponse> + Send + 'a;

	/// Processes multiple JSON-RPC calls at once, similar to `RpcServiceT::call`.
	///
	/// This method wraps `RpcServiceT::call` and `RpcServiceT::notification`,
	/// but the root RPC service does not inherently recognize custom implementations
	/// of these methods.
	///
	/// As a result, if you have custom logic for individual calls or notifications,
	/// you must duplicate that implementation in this method or no middleware will be applied
	/// for calls inside the batch.
	fn batch<'a>(&self, requests: Batch<'a>) -> impl Future<Output = Self::BatchResponse> + Send + 'a;

	/// Similar to `RpcServiceT::call` but processes a JSON-RPC notification.
	fn notification<'a>(&self, n: Notification<'a>) -> impl Future<Output = Self::NotificationResponse> + Send + 'a;
}

The reason for this change is to make it work for the client-side as well as make it easier to
with return impl Future instead require an associated type for the Future which in many cases
requires BoxFuture or ResponseFuture which improves ergonomics.

The downside of this change is that one has to duplicate the logic in the batch and call method to achieve the same
functionality as before. Thus, call or notification is not being invoked in the batch method and one has to implement
does separately.

For example now it's possible to write middleware that counts the number of method calls as follows (both client and server):

#[derive(Clone)]
pub struct Counter<S> {
	service: S,
	count: Arc<AtomicUsize>,
	role: &'static str,
}

impl<S> RpcServiceT for Counter<S>
where
	S: RpcServiceT + Send + Sync + Clone + 'static,
{
	type MethodResponse = S::MethodResponse;
	type NotificationResponse = S::NotificationResponse;
	type BatchResponse = S::BatchResponse;

	fn call<'a>(&self, req: Request<'a>) -> impl Future<Output = Self::MethodResponse> + Send + 'a {
		let count = self.count.clone();
		let service = self.service.clone();
		let role = self.role;

		async move {
			let rp = service.call(req).await;
			count.fetch_add(1, Ordering::SeqCst);
			println!("{role} processed calls={} on the connection", count.load(Ordering::SeqCst));
			rp
		}
	}

	fn batch<'a>(&self, batch: Batch<'a>) -> impl Future<Output = Self::BatchResponse> + Send + 'a {
		let len = batch.len();
		self.count.fetch_add(len, Ordering::SeqCst);
		println!("{} processed calls={} on the connection", self.role, self.count.load(Ordering::SeqCst));
		self.service.batch(batch)
	}

	fn notification<'a>(&self, n: Notification<'a>) -> impl Future<Output = Self::NotificationResponse> + Send + 'a {
		self.service.notification(n)
	}
}

In addition because this middleware is quite powerful it's possible to
modify requests and specifically the request ID which should be avoided
because it may break the response verification especially for the client-side.
See #1565 for further information.

There are also a couple of other changes see the detailed changelog below.

[Added]

  • middleware: RpcServiceT distinct return types for notif, batch, call (#1564)
  • middleware: add support for client-side (#1521)
  • feat: add namespace_separator option for RPC methods (#1544)
  • feat: impl Into for Infallible (#1542)
  • client: add request timeout getter (#1533)
  • server: add example how to close a connection from a rpc handler (method call or subscription) (#1488)
  • server: add missing ServerConfigBuilder::build (#1484)

[Fixed]

  • chore(macros): fix typo in proc-macro example (#1482)
  • chore(macros): fix typo in internal type name (#1507)
  • http middleware: preserve the URI query in ProxyGetRequest::call (#1512)
  • http middlware: send original error in ProxyGetRequest (#1516)
  • docs: update comment for TOO_BIG_BATCH_RESPONSE_CODE error (#1531)
  • fix http request body log (#1540)

[Changed]

  • unify usage of JSON via Box<RawValue> (#1545)
  • server: ServerConfigBuilder/ServerConfig replaces ServerBuilder duplicate setter methods (#1487)
  • server: make ProxyGetRequestLayer http middleware support multiple path-method pairs (#1492)
  • server: propagate extensions in http response (#1514)
  • server: add assert set_message_buffer_capacity (#1530)
  • client: add #[derive(Clone)] for HttpClientBuilder (#1498)
  • client: add Error::Closed for ws close (#1497)
  • client: use native async fn in traits instead async_trait crate (#1551)
  • refactor: move to rust edition 2024 (MSRV 1.85) (#1528)
  • chore(deps): update tower requirement from 0.4.13 to 0.5.1 (#1455)
  • chore(deps): update tower-http requirement from 0.5.2 to 0.6.1 (#1463)
  • chore(deps): update pprof requirement from 0.13 to 0.14 (#1493)
  • chore(deps): update rustls-platform-verifier requirement from 0.3 to 0.4 (#1489)
  • chore(deps): update thiserror requirement from 1 to 2 (#1491)
  • chore(deps): bump soketto to 0.8.1 (#1501)
  • chore(deps): update rustls-platform-verifier requirement from 0.4 to 0.5 (#1506)
  • chore(deps): update fast-socks5 requirement from 0.9.1 to 0.10.0 (#1505)
  • chore(deps): tokio ^1.42 (#1511)
  • chore: use cargo workspace dependencies (#1502)
  • chore(deps): update rand requirement from 0.8 to 0.9 (#1523)

@niklasad1 niklasad1 requested a review from a team as a code owner April 23, 2025 15:25
@niklasad1 niklasad1 requested a review from Copilot April 23, 2025 15:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

A release pull request updating the project with version v0.25.0, including breaking changes in the RpcServiceT trait to support both client- and server-side operations and multiple dependency bumps.

  • Bumps version numbers in Cargo.toml and updates internal dependencies.
  • Updates CHANGELOG.md to document new features, fixes, and breaking changes.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Cargo.toml Updated version and dependency versions to v0.25.0
CHANGELOG.md Added detailed release notes including new features and fixes

Co-authored-by: Copilot <[email protected]>
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@clint-long
Copy link

Merge and release quickly

Co-authored-by: James Wilson <[email protected]>
@niklasad1 niklasad1 merged commit 86763a9 into master Apr 24, 2025
10 checks passed
@niklasad1 niklasad1 deleted the chore-release-v0.25 branch April 24, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants