add json serialization#124
Conversation
9a6e2c7 to
3d5a1cd
Compare
| "cloud-events-version": "cloud-events-version value", | ||
| "event-id": "event-id value", | ||
| "namespace": "namespace value", | ||
| "source": { |
| } | ||
| ``` | ||
|
|
||
| Note: |
There was a problem hiding this comment.
nitpicking - sais Note, but these are notes.
| ``` | ||
|
|
||
| Note: | ||
| - the use of whitespace is not significant |
349dab1 to
c4fd2d5
Compare
| @@ -0,0 +1,43 @@ | |||
| # CloudEvents Serialization Profile - Version 0.1 | |||
|
|
|||
| This document specified how a CloudEvent is to be serialized into certain | |||
There was a problem hiding this comment.
Should this be applied here? s/specified/specifies/
There was a problem hiding this comment.
fixed the "specified" typo. What did you mean by "should this applied here?" ?
| } | ||
| ``` | ||
|
|
||
| Notes: |
There was a problem hiding this comment.
Should there be a comment about extra fields in the serialized data? Such as:
- It is undefined whether extra fields are passed along or removed depending on the usage role and implementation. Those fields are best placed in the extensions map.
There was a problem hiding this comment.
I expanded on the thought a little - see what you think.
There was a problem hiding this comment.
Thanks for the update. LGTM.
| } | ||
| ``` | ||
|
|
||
| Notes: |
There was a problem hiding this comment.
Thanks for the update. LGTM.
| CloudEvents seeks to ease event declaration and delivery across services, | ||
| platforms and beyond. | ||
|
|
||
| The [Serialization Profile](serialization.md) specified how to |
There was a problem hiding this comment.
This might be better as "specifies". (Or am I being too tense?)
There was a problem hiding this comment.
No, you're right - just a disconnect between the brain and fingers.
|
|
||
| ``` | ||
| { | ||
| "cloud-events-version": "cloud-events-version value", |
There was a problem hiding this comment.
I'm curious whether it would be more useful to use valid fake values rather than prose in quotes.
There was a problem hiding this comment.
I struggled with this because if we put fake values in there then we need something to say "property X from the spec goes into json property 'x'". While in many cases it should be really really obvious, I felt that a spec should be more explicit about it. If all we cared about was JSON I actually would have proposed that we have the serialization of each property next to its definition in the spec itself. But I didn't want to assume everyone would be ok with JSON getting special treatment.
There was a problem hiding this comment.
@inlined I added an example to try to address your concern. See if that helps.
| "extensions": { | ||
| ... extensions values ... | ||
| }, | ||
| "data": ... data value ... |
There was a problem hiding this comment.
As an FYI: though Google&Firebase started out with a model like this where all context is at the top level with one magic field called "data", we generally considered this to be a mistake. Many languages have better ways to expose context (e.g. Golang's Context.context, or JavaScript's variadic parameter system) so we are migrating to a world where data & context are exposed separately/natively our runtimes. Alpha testers have given very positive feedback for this because it allows any existing function(SomeNativeType) to be a CloudFunction<SomeNativeType>.
To match this, the REST JSON is being migrated to a two-field JSON object with {"context", "data"}
There was a problem hiding this comment.
I could live with that. What do other people think?
There was a problem hiding this comment.
@inlined would extensions be under context or another sibling at the root level?
There was a problem hiding this comment.
@inlined where would "could-events-version" go? I can see it being useful as a top-level thing since we may choose to rename data or context in a future version, but I can also see a need for that info to be passed downstream so people know how to interpret the context attributes based on our spec's version number.
I do want to explore this option, it feels cleaner - would make for a great follow-on PR
There was a problem hiding this comment.
would that be something that the definition of the content-type (e.g. json spec) would need to define?
There was a problem hiding this comment.
afaik json spec does not cover this explicitly. Most people seem to base64 encode data.
There was a problem hiding this comment.
yea, I did a quick search too and didn't find a lot. I guess we could offer some recommendations...
There was a problem hiding this comment.
Honestly I don't have the practical experience with content-type and cloud-events-version that I do with the other fields. Here's my first SWAG:
- In my opinion,
content-typeis/should be meta to the whole spec (why are we dictating the content type within a payload that's already explicitly JSON encoded?). This should be dictated in the transport layer, not the encoding layer. cloud-events-versionlooks cleanest at the top level in JSON though if it's going to show up in the programming model it might be easier to put it incontext.- I have the strong opinion (weakly held) that
extensionsshould be incontext. The developer is likely to depend on these extensions and they should be easily accessible.
There was a problem hiding this comment.
@inlined My understanding is that this PR is about how to package an arbitrary cloudevent into json. I was just wondering what happens if the content-type (the context attribute) is text/xml or image/png. The result is supposed to be a valid json object. So data would need to be encoded somehow. I don't see how this can be delegated to another layer. For events that use json for their data section, there is of course no need for encoding.
Signed-off-by: Doug Davis <dug@us.ibm.com>
Signed-off-by: Doug Davis <dug@us.ibm.com>
|
Added an example and one line to make it clear that optional fields are still optional, but if present then they MUST adhere to the rules defined. I think it was implied before but now its explicitly stated. |
|
This will have to be modified to be consistent with changed accepted today |
|
Approved on 3/29 call |
Closes #17
I would actually prefer if we just move this into the main spec itself since its so small, but for now I started out with it being in a separate doc with the assumption that we can decide on whether we want to merge it later.
Signed-off-by: Doug Davis dug@us.ibm.com