Skip to content

Implement new event streams API#1035

Merged
sugmanue merged 11 commits intosmithy-lang:mainfrom
sugmanue:sugmanue/event-stream-overhaul
Feb 27, 2026
Merged

Implement new event streams API#1035
sugmanue merged 11 commits intosmithy-lang:mainfrom
sugmanue:sugmanue/event-stream-overhaul

Conversation

@sugmanue
Copy link
Contributor

Issue #, if available:

Description of changes:

Implements a new event streams API that's VT friendly by blocking when the caller reads and writes events.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

try {
LOGGER.debug("Writing event {} (latch count: {})",
event.getClass().getSimpleName(),
readyLatch.getCount());
Copy link
Contributor

Choose a reason for hiding this comment

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

getCount incurs a volatile read of readyLatch's backing state, please only call this if debug logs are enabled

if (eventStream != null && operation instanceof InputEventStreamingApiOperation<?, ?, ?>) {
builder.body(EventStreamFrameEncodingProcessor.create(eventStream, eventStreamEncodingFactory));
ProtocolEventStreamWriter<SerializableStruct, SerializableStruct, Frame<?>> writer =
ProtocolEventStreamWriter.toInternal(eventStream);
Copy link
Member

Choose a reason for hiding this comment

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

toInternal seems like a leftover from the previous naming. Just call it of: ProtocolEventStreamWriter.of

sugmanue and others added 3 commits February 25, 2026 18:01
Co-authored-by: Michael Dowling <michael@mtdowling.com>
int read = inputStream.read(buffer);

if (read == -1) {
var error = new IOException("Unexpected end of stream while reading initial event");
Copy link
Member

Choose a reason for hiding this comment

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

This is going to catch the IOException and call closeWithError twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

duh, let me just throw the exception as originally suggested 🤦

/**
* Default timeout to block waiting to write.
*/
private static final int WRITE_TIMEOUT_MILLIS = 1500;
Copy link
Member

Choose a reason for hiding this comment

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

Main concern here is -- is this universally enough time? I am not positive 1.5 seconds is enough. Not sure if this has to be configurable yet, but maybe this should be more like 10 seconds or something like that to account for long setup, but still give some mitigation against hanging forever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I don't think there's a way to finding that out, 1.5 seemed like a good one but we can use 10 as well. Let me change it.

@sugmanue sugmanue merged commit 699cb3e into smithy-lang:main Feb 27, 2026
2 checks passed
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