In the current version of SDK, one has to deal with generic signature of CloudEvent and an unnecessary allocation of the AttributesImpl object.
While working on CloudEvents for Liiklus, I had to implement our own CloudEvent type that implements both CloudEvent and Attributes to reduce the allocations (see the link)
Since (according to the spec) there is always an 1:1 mapping of an event and its attributes, I suggest to remove the interface and make the fields part of the CloudEvent interface.
To make the change less impactful and support a migration path, I suggest we do it in two steps (that should be released separately):
- Make
CloudEvent implementations implement both CloudEvent and Attributes and return this from getAttributes()
- Make
CloudEvent extend from Attributes and turn getAttributes() into a default method that returns this and deprecate getAttributes() and Attributes
- Remove
Attributes and ``getAttributes()and move the fields to theCloudEvent` interface
If the community agrees, I can work on all 3 PRs.
In the current version of SDK, one has to deal with generic signature of
CloudEventand an unnecessary allocation of theAttributesImplobject.While working on CloudEvents for Liiklus, I had to implement our own
CloudEventtype that implements bothCloudEventandAttributesto reduce the allocations (see the link)Since (according to the spec) there is always an 1:1 mapping of an event and its attributes, I suggest to remove the interface and make the fields part of the
CloudEventinterface.To make the change less impactful and support a migration path, I suggest we do it in two steps (that should be released separately):
CloudEventimplementations implement bothCloudEventandAttributesand returnthisfromgetAttributes()CloudEventextend fromAttributesand turngetAttributes()into a default method that returnsthisand deprecategetAttributes()andAttributesAttributesand ``getAttributes()and move the fields to theCloudEvent` interfaceIf the community agrees, I can work on all 3 PRs.