Giter Site home page Giter Site logo

Nested events? about spec HOT 17 CLOSED

cloudevents avatar cloudevents commented on June 26, 2024
Nested events?

from spec.

Comments (17)

cathyhongzhang avatar cathyhongzhang commented on June 26, 2024

This is related to the question I raised in last week's meeting. For this case, is the SaaS application the event source or API GW the event source? If API GW is the event source, event data from SaaS Application should be the payload of the API GW event (the Alternative 1) and some metadata needs to be added to the API GW event metadata fields so that the event consumer knows how to extract needed info from the SaaS data.

from spec.

duglin avatar duglin commented on June 26, 2024

With the HTTP/JSON structured format, where the content type is "application/cloudevents+json", I would think that a nested CE would have its CE contentType property set to "app/ce+json" and then data would be the nested CE as json. no? If so, is there anything to formalize in the spec about this or would perhaps adding a sample be sufficient?

from spec.

deissnerk avatar deissnerk commented on June 26, 2024

Yes, that sounds like a good solution. What do you think, @cathyhongzhang ?

from spec.

duglin avatar duglin commented on June 26, 2024

Related to #87 ?

from spec.

duglin avatar duglin commented on June 26, 2024

@deissnerk what are your thoughts on this one? If an example is sufficient, would you be interested in creating a PR?

from spec.

deissnerk avatar deissnerk commented on June 26, 2024

@duglin I think that the case I brought up, may not be that relevant in practice. The event on the API gateway is probably not worth wrapping into a CloudEvent on its own. Nevertheless there might be cases, when people decide to nest CloudEvents for whatever reason. So having an example makes sense.

I can create a PR with an example outlining the idea you brought up. It might take a few weeks, though.

from spec.

duglin avatar duglin commented on June 26, 2024

ok thanks

from spec.

duglin avatar duglin commented on June 26, 2024

@deissnerk any update on this one?

from spec.

duglin avatar duglin commented on June 26, 2024

@deissnerk can we close this one or do you think we need to add some text in the primer to explain how people could put a CE into the data attribute of an existing CE (if they wanted)?

from spec.

deissnerk avatar deissnerk commented on June 26, 2024

@duglin I was just about to create an example according to your proposal above. It turns out, that this does not work, if you put a nested event inside an event that is sent using http binary mode. Our http protocol binding states:

The receiver of the event can distinguish between the three modes by inspecting the Content-Type header value. If the value is prefixed with the CloudEvents media type application/cloudevents, indicating the use of a known event format, the receiver uses structured mode. If the value is prefixed with application/cloudevents-batch, the receiver uses the batched mode. Otherwise it defaults to binary mode.

By this rule, a receiver will retrieve the inner event only. If you send an outer event in binary mode with content type "application/cloudevents+json", the event context in the http header will be ignored. I just checked this with the go sdk.
Does that mean we should advise people, that nesting is only possible, if you do not mix binary and structured mode?

from spec.

duglin avatar duglin commented on June 26, 2024

Just to be clear, we're talking about how this:

Content-Type: application/cloudevents+json
ce-specversion: 1.0
ce-type: myevent
ce-id: 1234-1234-1234
ce-source: example.com

{
  "specversion": "1.0",
  "type": "coolevent",
  "id": "xxxx-xxxx-xxxx",
  "source": "bigco.com",
  "data": { ... }
}

is ambiguous, right?

I wonder if it wouldn't make more sense to change the spec slightly to talk about how checking for ce-specversion HTTP header might be the better choice. The text in there is non-normative :-)

from spec.

deissnerk avatar deissnerk commented on June 26, 2024

@duglin Yes, that's the case I was talking about. I agree, it would be more consistent to adjust the spec as you proposed. I'm just not sure, if that is still possible. Is this not normative?
By the way, there is still the document status:

This document is a working draft.

from spec.

duglin avatar duglin commented on June 26, 2024

Well, in general there is normative text in there, but unless I'm missing it I don't see any normative text that mandate how people determine binary vs structured.

I'll PR the "working draft" thing :-)

from spec.

deissnerk avatar deissnerk commented on June 26, 2024

@duglin I see your point. There is no MUST, SHOULD etc. It will nevertheless have an impact on implementations. I only checked the go-sdk so far, but I would expect others distinguish structured and binary the same way.

from spec.

duglin avatar duglin commented on June 26, 2024

I agree it would impact implementations, but from a spec perspective I think we could modify the text to talk about using the ce-specversion header instead of Content-Type w/o requiring a version bump.

from spec.

duglin avatar duglin commented on June 26, 2024

@deissnerk any update on this one?

from spec.

duglin avatar duglin commented on June 26, 2024

This would be the way to do it:

Content-Type: application/json
ce-specversion: 1.0
ce-type: myevent
ce-id: 1234-1234-1234
ce-source: example.com

{
  "specversion": "1.0",
  "type": "coolevent",
  "id": "xxxx-xxxx-xxxx",
  "source": "bigco.com",
  "data": { ... }
}

from spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.