-
Notifications
You must be signed in to change notification settings - Fork 897
Duplicate all eventstream event shapes + add new legacy event modes #6052
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: master
Are you sure you want to change the base?
Duplicate all eventstream event shapes + add new legacy event modes #6052
Conversation
...re/amazon/awssdk/codegen/customization/processors/EventStreamUniqueEventShapesProcessor.java
Outdated
Show resolved
Hide resolved
The current non-legacy way is there's a package per eventstream, e.g. |
We could, but it would require fairly large changes in multiple parts of the code generation and require maintaining 3 separate paths through codegen (for each of the cases) including marshallers, builders and others. The benefit of renaming the shape up front is that all other parts of the codegen are able to remain the same, but it doesn't let us change the packaging/namespace of the generated classes. |
I did try to put together a POC for this but It would require a much more significant refactoring to get working. There are a few issues/sharp edges:
|
|
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