Repository navigation
feat: add MQTT transport messaging - #459
Merged
Merged
Conversation
Signed-off-by: Lance Ball <lball@redhat.com>
Merged
grant
approved these changes
Jan 12, 2022
grant
left a comment
Member
There was a problem hiding this comment.
Fine with me :)
Might want to add some more comments for readability and better IDE devX.
Comment on lines
+14
to
+36
| const type = "org.cncf.cloudevents.example"; | ||
| const source = "urn:event:from:myapi/resource/123"; | ||
| const time = new Date().toISOString(); | ||
| const subject = "subject.ext"; | ||
| const dataschema = "http://cloudevents.io/schema.json"; | ||
| const datacontenttype = "application/json"; | ||
| const id = "b46cf653-d48a-4b90-8dfa-355c01061361"; | ||
|
|
||
| interface Idata { | ||
| foo: string | ||
| } | ||
| const data: Idata = { | ||
| foo: "bar", | ||
| }; | ||
|
|
||
| const ext1Name = "extension1"; | ||
| const ext1Value = "foobar"; | ||
| const ext2Name = "extension2"; | ||
| const ext2Value = "acme"; | ||
|
|
||
| // Binary data as base64 | ||
| const dataBinary = Uint32Array.from(JSON.stringify(data), (c) => c.codePointAt(0) as number); | ||
| const data_base64 = asBase64(dataBinary); |
Member
There was a problem hiding this comment.
nit: it may be better to keep/group related constants in an object rather than having a bunch of individual consts.
lholmquist
approved these changes
Jan 12, 2022
Signed-off-by: Lance Ball <lball@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Add MQTT as a
Messageformat.Description
This commit adds
MQTTto the supported transport protocols by adding aBindingand theMQTTMessage<T>type, extending the baseMessagetype, adding the MQTT fields forpayload,PUBLISHandUser Properties. Thepayloadfield directly maps toMessage#body, whileUser Propertiesroughly maps toMessage#headers, even though the properties here are not formatted with ace-prefix like other transport protocols. This is per the spec. See: https://github.com/cloudevents/spec/blob/v1.0.1/mqtt-protocol-binding.md. ThePUBLISHproperty is there primarily to support the"Content type"and perhaps should be typed better. Feedback welcome.