Skip to content

Support server-streaming in transcoding - #284

Open
zZHorizonZz wants to merge 5 commits into
eclipse-vertx:mainfrom
zZHorizonZz:transcoding-streaming
Open

Support server-streaming in transcoding#284
zZHorizonZz wants to merge 5 commits into
eclipse-vertx:mainfrom
zZHorizonZz:transcoding-streaming

Conversation

@zZHorizonZz

Copy link
Copy Markdown
Member

Motivation:

  • Extend JSON transcoding support for server-streaming RPCs to enhance compatibility with streaming APIs.
  • Improve response flexibility with support for JSON Array, NDJSON, and SSE formats based on the Accept header.

Changes:

  • Added streaming and StreamFormat fields to TranscodingGrpcOutboundStream for response format negotiation.
  • Implemented JSON Array, NDJSON, and SSE response formatting for server-streaming.
  • Updated MessageWeaver to handle JsonObject outputs for request/response weaving.
  • Modified tests to validate new streaming response formats and HTTP transcoding logic.
  • Refactored templates (grpc-service.mustache) and tests to support method-level isManyOutput configurations.

@zZHorizonZz zZHorizonZz changed the title Enable JSON transcoding for server-streaming RPCs and refine response formatting Enable JSON transcoding for server-streaming RPCs Jun 30, 2026
@zZHorizonZz

Copy link
Copy Markdown
Member Author

This PR depends on #281

@zZHorizonZz zZHorizonZz changed the title Enable JSON transcoding for server-streaming RPCs Support server-streaming in transcoding Jul 1, 2026
@zZHorizonZz zZHorizonZz added this to the 5.2.0 milestone Jul 1, 2026
@zZHorizonZz
zZHorizonZz force-pushed the transcoding-streaming branch 2 times, most recently from 53c01e2 to 911fe6b Compare August 16, 2026 10:28
@zZHorizonZz
zZHorizonZz marked this pull request as ready for review August 16, 2026 11:24
@zZHorizonZz
zZHorizonZz requested a review from vietj August 16, 2026 15:32
@zZHorizonZz
zZHorizonZz force-pushed the transcoding-streaming branch 4 times, most recently from 857e4de to 4a8f270 Compare August 25, 2026 16:18
@zZHorizonZz
zZHorizonZz force-pushed the transcoding-streaming branch from 4a8f270 to b38488c Compare September 1, 2026 13:21

=== Server-streaming responses

Server-streaming RPCs (`rpc Foo (Req) returns (stream Resp)`) are transcoded by emitting the response over chunked transfer encoding. The wire format is selected per-request from the HTTP `Accept` header so clients can pick the encoding that fits their consumption pattern without any server configuration:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"according to the HTTP accept header letting the client choose the most appropriate encoding"

# data: {"payload":"second"}
----

If the RPC terminates with a non-OK gRPC status before any message has been written, the response is finished with the corresponding HTTP status code and no body. If messages have already been written, the stream ends (with the closing `]` for JSON array mode). Mid-stream errors cannot be signalled on the body since the HTTP status was already sent.

@vietj vietj Sep 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rather:

  • gRPC trailers-only response sends the corresponding HTTP status error without content
  • gRPC trailers response terminates the response with ], such error cannot be reported to the client


If the RPC terminates with a non-OK gRPC status before any message has been written, the response is finished with the corresponding HTTP status code and no body. If messages have already been written, the stream ends (with the closing `]` for JSON array mode). Mid-stream errors cannot be signalled on the body since the HTTP status was already sent.

Client-streaming and bidirectional-streaming RPCs are not supported by transcoding.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rather : Transcoding does not support ...

@vietj vietj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few docs style wording changes would improve the quality.

… formatting.

Motivation:

- Extend JSON transcoding support for server-streaming RPCs to enhance compatibility with streaming APIs.
- Improve response flexibility with support for JSON Array, NDJSON, and SSE formats based on the `Accept` header.

Changes:

- Added `streaming` and `StreamFormat` fields to `TranscodingGrpcOutboundStream` for response format negotiation.
- Implemented JSON Array, NDJSON, and SSE response formatting for server-streaming.
- Derived the streaming cardinality from `ServiceMethod#serverStreaming()`.
- Updated `MessageWeaver` to handle `JsonObject` outputs for request/response weaving.
- Modified tests to validate new streaming response formats and HTTP transcoding logic.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
Motivation:

- The server-streaming transcoding formats were only covered by unit tests using hand-built service methods, leaving the protoc plugin path untested end to end.

Changes:

- Exercise the generated `StreamingTranscodingGreeter` service method over HTTP for the JSON array, NDJSON and SSE formats.
- Cover the empty stream and the coexistence of the transcoded and gRPC routes for the same method.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
Motivation:

- `GrpcServer#addService` only registered the canonical `/package.Service/Method` path, so the HTTP rules of a transcoded service method were ignored and the transcoded routes returned a 500. `GrpcServer#callHandler` already mounts these paths.

Changes:

- Mount the `MountPoint` paths of a service method in `addService`, like `callHandler` does.
- Add integration tests binding a transcoded unary and server-streaming service with `addService`.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
… message.

Motivation:

Transcoding defers the HTTP head until the response body is known, so writeHead returns a
promise resolved by writeUnaryMessage. A unary call that ends without ever writing a message
never resolves it and leaves the caller waiting.

Changes:

Resolve the head promise from writeEnd when it is still pending.

Fix the indentation of the SSE branch.
Motivation:

- Review feedback on the server-streaming transcoding section asked for a more concise wording of the content negotiation and error reporting paragraphs.

Changes:

- Describe the wire format as selected according to the HTTP `accept` header.
- Split the error reporting paragraph into the trailers-only and trailers cases.
- Reword the unsupported streaming modes sentence.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
@zZHorizonZz
zZHorizonZz force-pushed the transcoding-streaming branch from b38488c to fd3fe78 Compare September 3, 2026 17:09
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.

2 participants