-
Notifications
You must be signed in to change notification settings - Fork 967
Support server-sent events in JsonRpcService
#6487
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
base: json-rpc
Are you sure you want to change the base?
Conversation
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.
| * The parameters can be either positional (a {@link List}) or named (a {@link Map}). | ||
| */ | ||
| @UnstableApi | ||
| public final class JsonRpcParameters { |
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.
Renamed from JsonRpcParameter
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Motivation:
We can easily implement other protocols such as MCP on top of
JsonRpcServiceby adding SSE support.Modifications:
JsonRpcHandlercan handleJsonRpcResponseandJsonRpcNotifcation.JsonRpcMessageas the root interface of JSON-RPC messages.JsonRpcStreamableResponseis newly added to allow writing multiple JSON-RPC messages before emitting a final response.JsonRpcService.JsonRpcExceptionHandleris added to recover an exception into aJsonRpcResponse.JsonRpcHandlerintoJsonRpcMehtodHandlerand the orignal interface is used as a global handler to process any JSON-RPC messages.JsonRpcStatusFunctionmaps aJsonRpcErrorinto an HTTP status.WebClient.prepare().asJson()API.Result:
JsonRpcService.Future work:
armeria-jsonrpcmodule.