Duplicate all eventstream event shapes + add new legacy event modes #6052
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.
Fix issues with eventstreams with shared event shapes: Rename all eventstream event shapes with a unique name + add new legacy event modes.
Motivation and Context
When an event shape is shared between multiple eventstreams, it causes SDK generation/compilation failures. The top level shape POJO implements the event stream interface for each stream and the return type of the sdkEventType method conflicts.
Modifications
This PR does two things:
useLegacyEventGenerationScheme
to take an enum per event shape - the old legacy event generation usesNO_EVENT_SUBCLASS
and the current behavior usesNO_UNIQUE_EVENT_NAMES
.useLegacyEventGenerationScheme
is unset orDEFAULT
for an event, the event shape will be duplicated and given a unique name:<ShapeName><EventStreamName>
.Note: There are a large number of changes in the codegen test to add the new customization mode to existing test eventstreams.
Open Questions
What naming scheme should we use to produce unique names?
This PR currently uses
<ShapeName><EventStreamName>
, for example an event namedPayload
in eventstreamStreamA
would get the name:PayloadStreamA
. We could reverse this (StreamAPayload
).The downside of this naming scheme is that it can produce long names. For example the existing HeartbeatEvent from LexRuntimeV2's StartConversationResponseEventStream would be (without the legacy customization) renamed to:
HeartbeatEventStartConversationResponseEventStream
.FAQ
Why do we always need to rename the event shape? Couldn't we do that only when there is a shared event?
We must ensure that shapes names are deterministic and do not depend on the shapes in the model because if a shared event shape is added in the future, we have no way of telling which was the existing shape.
Alternatives
For POCs of alternative approaches see:
TODO:
User Experience
There are no changes for users for any existing Eventstreams/events. New eventstreams or new events added to existing evenstreams will have unique, longer names, but the fluid visitor and builder methods will continue to use the member names. For example, assuming we have
Payload
event (with member name "PayloadEvent") in eventstreamStreamA
, the handler and builder methods will still beonPayloadEvent
andpayloadEventBuilder
.Note: For users using switch/case or if/else on
sdkEventType
or checkinginstance of
, when casting the events they will need to use the longer shape names. Using the example from above:Testing
New Unit tests - see shared event stream cases (model was modified to add new streams that share an event)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License