Skip to content

feat!: expose a version agnostic event emitter - #141

Merged
lance merged 6 commits into
cloudevents:masterfrom
lance:124-version-agnostic-emitter
May 14, 2020
Merged

lance merged 6 commits into
cloudevents:masterfrom
lance:124-version-agnostic-emitter

Conversation

@lance

@lance lance commented May 11, 2020

Copy link
Copy Markdown
Member

This is a breaking change.

This commit exposes an HTTP based event emitter that simplifes the API.
To use it, simply import the SDK and start emitting. The default spec
version is 1.0, but you can use 0.3 by supplying that to the constructor.

By default, CloudEvents are emitted in binary mode, but this can be changed
by providing the "structured" parameter to the emit() function.

This commit also eliminates the version specific emitters and receivers
from the v1 and v03 exports, and eliminates the explicit usage of
versioned emitters from lib/bindings/http.

Fixes: #124

Signed-off-by: Lance Ball lball@redhat.com

@lance lance added type/enhancement New feature or request module/transport/http Issues related to the HTTP transport protocol implementation labels May 11, 2020
@lance
lance requested review from fabiojose, grant and helio-frota May 11, 2020 23:23
Comment thread lib/bindings/http/emitter_binary.js Resolved
Comment thread lib/bindings/http/emitter_binary.js Resolved
Comment thread test/sdk_test.js Resolved
Comment thread test/sdk_test.js Resolved
@lance
lance marked this pull request as draft May 12, 2020 14:35
@lance

lance commented May 12, 2020

Copy link
Copy Markdown
Member Author

@danbev thanks for the review - I think I was a bit early in submitting this. I want to add more tests and docs. Marking as WIP for now.

Comment thread lib/bindings/http/http_emitter.js Resolved

@lance lance left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@danbev I've incorporated your comments - thanks!

Comment thread .eslintrc Resolved
@lance
lance marked this pull request as ready for review May 12, 2020 21:25
@lance

lance commented May 12, 2020

Copy link
Copy Markdown
Member Author

OK - I think I've covered my bases here. Tests and docs added. PTAL.

@danbev @helio-frota if you wouldn't mind another review, I'd appreciate it.

@helio-frota
helio-frota self-requested a review May 13, 2020 17:40
@lance
lance requested a review from helio-frota May 13, 2020 19:35
@lance

lance commented May 13, 2020

Copy link
Copy Markdown
Member Author

@helio-frota @danbev - I've modified the API a little bit. If you have a chance, PTAL.

@erikerikson erikerikson 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.

I think these changes are broadly an improvement, thank you for them.

Two concerns that may exceed the appropriate scope of this PR and should be raised as issues:

As expressed on Slack: those who care about ordering will be excluded by the design assumptions currently encoded here.

Another potential point of exclusion is the explicitly expressed transport. Perhaps a transport agnostic API could be offered that allows the specification of the transport? Of course, it would only support HTTP until an alternative is offered but it seems this base-level API change work should prepare for that future.

Comment thread README.md
.type("com.github.pull.create")
.source("urn:event:from:myapi/resource/123");
By default, the `HTTPEmitter` will emit events over HTTP POST using the
1.0 specification, in binary mode. You can emit 0.3 events by providing

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.

"1.0" => "latest supported"?

In general, the version specific comments throughout these docs will have a short shelf life.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@erikerikson that's a valid point. I would like to avoid having that hold up the PR, so I've added a new issue to address it #160. Work for you?

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.

Works for me

lance added 6 commits May 13, 2020 17:47
This is a breaking change.

This commit exposes an HTTP based event emitter that simplifes the API.
To use it, simply import the SDK and start emitting. The default spec
version is 1.0, but you can use 0.3 by supplying that to the constructor.

By default, CloudEvents are emitted in binary mode, but this can be changed
by providing the "structured" parameter to the `emit()` function.

This commit also eliminates the version specific emitters and receivers
from the `v1` and `v03` exports, and eliminates the explicit usage of
versioned emitters from `lib/bindings/http`.

Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
Fixes: cloudevents#149

Signed-off-by: Lance Ball <lball@redhat.com>
@lance
lance force-pushed the 124-version-agnostic-emitter branch from 9b864b4 to 0b27c61 Compare May 13, 2020 22:09

@grant grant 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.

Looks like improvements all-around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module/transport/http Issues related to the HTTP transport protocol implementation type/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eliminate up-front spec version awareness in the emitter

5 participants