Skip to content
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

feat!: expose a version agnostic event emitter #141

Merged
merged 6 commits into from
May 14, 2020

Conversation

lance
Copy link
Member

@lance lance commented May 11, 2020

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
lib/bindings/http/emitter_binary.js Outdated Show resolved Hide resolved
lib/bindings/http/emitter_binary.js Outdated Show resolved Hide resolved
test/sdk_test.js Outdated Show resolved Hide resolved
test/sdk_test.js Outdated Show resolved Hide resolved
@lance lance marked this pull request as draft May 12, 2020 14:35
@lance
Copy link
Member Author

lance commented May 12, 2020

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

Copy link
Member Author

@lance lance left a comment

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!

.eslintrc Outdated Show resolved Hide resolved
@lance lance marked this pull request as ready for review May 12, 2020 21:25
@lance
Copy link
Member Author

lance commented May 12, 2020

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
Copy link
Member Author

lance commented May 13, 2020

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

Copy link
Member

@erikerikson erikerikson left a comment

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.

.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
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
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
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
Copy link
Member

@grant grant left a comment

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