Skip to content

Conversation

@ikhoon
Copy link
Contributor

@ikhoon ikhoon commented Nov 11, 2025

Motivation:

We can easily implement other protocols such as MCP on top of JsonRpcService by adding SSE support.

Modifications:

  • Reorganized JSON-RPC message data types so that JsonRpcHandler can handle JsonRpcResponse and JsonRpcNotifcation.
    • Introduced JsonRpcMessage as the root interface of JSON-RPC messages.
  • JsonRpcStreamableResponse is newly added to allow writing multiple JSON-RPC messages before emitting a final response.
    • The streamable response is converted to SSE by JsonRpcService.
  • JsonRpcExceptionHandler is added to recover an exception into a JsonRpcResponse.
  • Renamed JsonRpcHandler into JsonRpcMehtodHandler and the orignal interface is used as a global handler to process any JSON-RPC messages.
  • JsonRpcStatusFunction maps a JsonRpcError into an HTTP status.
  • Because testing non-OK JSON responses was difficult, a predicate-based HTTP status check was added to the WebClient.prepare().asJson() API.

Result:

  • Several handlers have been added to customize the behavior of JsonRpcService.
  • You can now stream JSON-RPC messages over server-sent events.

Future work:

  • Extract the JSON-RPC code into armeria-jsonrpc module.

Motivation:

We can easily implement other protocols such as MCP on top of
`JsonRpcService` by adding SSE support.

Modifications:

- Reorganized JSON-RPC message data types so that `JsonRpcHandler`
  can handle `JsonRpcResponse` and `JsonRpcNotifcation`.
  - Introduced `JsonRpcMessage` as the root interface of JSON-RPC
    messages.
- `JsonRpcStreamableResponse` is newly added to allow writing multiple
  JSON-RPC messages before emitting a final response.
  - The streamable response is converted to SSE by `JsonRpcService`.
- `JsonRpcExceptionHandler` is added to recover an exception into a
  `JsonRpcResponse`.
- Renamed `JsonRpcHandler` into `JsonRpcMehtodHandler` and the orignal
  interface is used as a global handler to process any JSON-RPC
  messages.
- `JsonRpcStatusFunction` maps a `JsonRpcError` into an HTTP status.

Result:

- Several handlers have been added to customize the behavior of JsonRpcService.
- You can now stream JSON-RPC messages over server-sent events.
@ikhoon ikhoon marked this pull request as draft November 11, 2025 06:18
* The parameters can be either positional (a {@link List}) or named (a {@link Map}).
*/
@UnstableApi
public final class JsonRpcParameters {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed from JsonRpcParameter

@ikhoon ikhoon added this to the 1.34.0 milestone Nov 12, 2025
@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 73.83367% with 129 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (json-rpc@3ce41df). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...corp/armeria/common/jsonrpc/JsonRpcParameters.java 55.73% 17 Missing and 10 partials ⚠️
...inecorp/armeria/server/jsonrpc/JsonRpcService.java 85.07% 7 Missing and 13 partials ⚠️
...armeria/common/jsonrpc/DefaultJsonRpcResponse.java 69.23% 4 Missing and 8 partials ⚠️
...eria/common/jsonrpc/JsonRpcStreamableResponse.java 27.27% 7 Missing and 1 partial ⚠️
...ria/common/jsonrpc/DefaultJsonRpcNotification.java 56.25% 2 Missing and 5 partials ⚠️
...server/jsonrpc/DefaultJsonRpcExceptionHandler.java 41.66% 5 Missing and 2 partials ⚠️
...mmon/jsonrpc/DefaultJsonRpcStreamableResponse.java 73.91% 3 Missing and 3 partials ⚠️
...ria/internal/common/jsonrpc/JsonRpcSseMessage.java 71.42% 2 Missing and 4 partials ⚠️
...ia/client/BlockingWebClientRequestPreparation.java 54.54% 5 Missing ⚠️
...armeria/common/jsonrpc/AbstractJsonRpcRequest.java 70.58% 2 Missing and 3 partials ⚠️
... and 8 more
Additional details and impacted files
@@             Coverage Diff             @@
##             json-rpc    #6487   +/-   ##
===========================================
  Coverage            ?   74.17%           
  Complexity          ?    23221           
===========================================
  Files               ?     2087           
  Lines               ?    86775           
  Branches            ?    11392           
===========================================
  Hits                ?    64363           
  Misses              ?    16966           
  Partials            ?     5446           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ikhoon ikhoon marked this pull request as ready for review November 12, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant