Skip to content

Refactor to Facilitate Decoupling from Concrete Implementations of EventFormat - #539

Merged
pierDipi merged 8 commits into
cloudevents:mainfrom
skepticoitusInteruptus:537-refactor-facilitate-decoupling-from-eventformat-impl
Apr 21, 2023
Merged

pierDipi merged 8 commits into
cloudevents:mainfrom
skepticoitusInteruptus:537-refactor-facilitate-decoupling-from-eventformat-impl

Conversation

@skepticoitusInteruptus

Copy link
Copy Markdown
Contributor

Closes #537

Example Usage of Proposed Refactor

import io.cloudevents.CloudEvent;
import io.cloudevents.core.format.EventFormatProvider;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.core.format.ContentType; // New constant to facilitate loose coupling in client applications

CloudEvent event = ...;

byte[] serialized = EventFormatProvider
    .getInstance()
    .resolveFormat(ContentType.PROTO) // EventFormatProvider.resolveFormat(...) overloaded 
    .serialize(event);                // for string and enum input options

@skepticoitusInteruptus
skepticoitusInteruptus force-pushed the 537-refactor-facilitate-decoupling-from-eventformat-impl branch from 8f82cdb to 02b5bd1 Compare March 23, 2023 15:27

@JemDay JemDay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like you need to sign your 'git commit' to get the build to run.

I do like how this cleans up the dependencies, may need to tweak the documentation on the ContentType to make it clear it's only enumerating the types defined by the various CloudEvent formats.

Comment thread core/src/main/java/io/cloudevents/core/format/ContentType.java Outdated
@JemDay

JemDay commented Mar 23, 2023

Copy link
Copy Markdown
Contributor

And it looks like you 'pushed' while I was commenting :-)

Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
@skepticoitusInteruptus

Copy link
Copy Markdown
Contributor Author

And it looks like you 'pushed' while I was commenting :-)

Yeah. I didn't intend to push so many commits. I tried (in vain) to rebase all but one of them away. But I ended up with even more than I started out with.

I suck at git. Haha!

Comment thread formats/json-jackson/src/main/java/io/cloudevents/jackson/JsonFormat.java Outdated
Comment thread core/src/main/java/io/cloudevents/core/format/ContentType.java Outdated
Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
@skepticoitusInteruptus
skepticoitusInteruptus force-pushed the 537-refactor-facilitate-decoupling-from-eventformat-impl branch from 53e6081 to e1dbe9c Compare April 1, 2023 17:30
Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Comment thread formats/json-jackson/src/main/java/io/cloudevents/jackson/JsonFormat.java Outdated
Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Comment thread core/src/main/java/io/cloudevents/core/provider/EventFormatProvider.java Outdated
Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>

@pierDipi pierDipi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

LGTM

@pierDipi
pierDipi merged commit 4ebeab0 into cloudevents:main Apr 21, 2023
alexec pushed a commit to alexec/sdk-java that referenced this pull request Jun 6, 2023
…entFormat (cloudevents#539)

- Introduce ContentType enum
- Resolve formats by using the ContentType enum

Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
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.

Remove Clients' Dependency on Concrete Implementations of EventFormat

3 participants