feat(codegen): experimental SSE (text/event-stream) event stream protocol#2177
Draft
goelakash wants to merge 2 commits into
Draft
feat(codegen): experimental SSE (text/event-stream) event stream protocol#2177goelakash wants to merge 2 commits into
goelakash wants to merge 2 commits into
Conversation
Server SDK generation stubbed the event stream serde context type as `& any` and never supplied an event stream marshaller, so generated SSDK code for operations with event streams did not type-check. Type the response serializer / request deserializer context with __EventStreamSerdeContext, and wire the Node eventStreamSerdeProvider into the handler's serde context base (it only needs utf8 encode/decode, which the base already provides). Adds server event stream codegen tests, which were previously absent.
Adds an experimental sseJson protocol whose event streams are framed as Server-Sent Events instead of the binary vnd.amazon.eventstream encoding, so a Smithy model can generate a server that streams over text/event-stream. - SseEventStreamMarshaller in @smithy/core/event-streams: an EventStreamMarshaller that frames messages as SSE, with the same options and callback contract as the binary marshaller. - ProtocolGenerator.getEventStreamSerdeProviderName lets a protocol choose which provider the generated handler wires into its serde context; defaults to the binary provider. - SseJsonProtocolGenerator + sseJson trait: an HTTP protocol that overrides the provider to emit the SSE marshaller. Document body serde for non-streaming members is not yet implemented. Gated behind the experimentalSseProtocol smithy-build setting; when unset, the protocol is not registered and codegen output is unchanged.
This was referenced Jul 22, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements the proposal in #2176: lets a Smithy model generate a server whose event streams are framed as Server-Sent Events (
text/event-stream) instead of the binaryvnd.amazon.eventstreamencoding.Opt-in, twice over: everything is gated behind the
experimentalSseProtocolsmithy-build setting (registered in the CONTRIBUTING experimental-features table), and even then only activates on services carrying the newsseJsontrait. With the flag unset — the default — the protocol isn't registered and codegen output is byte-for-byte unchanged; a test asserts this.What's inside:
SseEventStreamMarshallerin@smithy/core/event-streams: same options and callback contract as the binary marshaller, so the two are interchangeable. Maps:event-typeto the SSEevent:field, body todata:line(s), modeled exceptions toevent: exception:<code>. WHATWG-spec line-terminator handling (CR/LF/CRLF), incremental cross-chunk parsing.ProtocolGenerator.getEventStreamSerdeProviderName(): a protocol can now choose which provider the generated handler wires into its serde context (default: binary). This is the seam from fix(codegen): support event streams in server SDK serde context #2175.sseJsontrait +SseJsonProtocolGenerator: an HTTP-binding protocol that selects the SSE provider. Scope note: document body serde for non-streaming members is stubbed — this PR is about the event stream framing; full JSON body serde is follow-up work.Testing: marshaller round-trip/chunk-boundary/CR-CRLF/exception specs; codegen tests generating an SSDK from an
@sseJsonmodel asserting the SSE provider wiring; a gate test proving inertness without the flag. Full gradle build passes (checkstyle, spotbugs).Note: this branch is stacked on #2175 (its first commit) — the serde-context seam it builds on.