GoogleCloudPlatform/functions-framework-php

Update behavior for event vs cloudevent function signature type

Closed this issue · 9 comments

The new behavior will be as follows:

  • The function framework will accept legacy events and convert to a CloudEvent type for both event and cloudevent function signature types
  • User-provided functions will be validated at runtime to ensure the folliowing:
    • The function accepts exactly one parameter argument
    • The argument must be RequestInterface if the function signature type is http
    • The argument must be CloudEvent if the function signature type is event or cloudevent
    • The framework will throw an exception if any of the above conditions fail.
  • Use functions-framework-conformance tests to verify

Sounds good to me. Thanks!

@mtraver how do we tell a legacy event from a cloudevent? Is it by the presence of the JSON data property?

grant commented

Node is similar, checking the 4 headers.
https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/master/src/cloudevents.ts#L28

Note, we should also check if application/cloudevents+json (although GCP just needs the headers)

@mtraver this is very helpful, thank you. A few things:

  1. The python code you provided does not convert from Event to CloudEvent, which we've decided to do here. Is there a standard way of converting from Event to CloudEvent?
  2. We do not differ between a "structured" vs "binary" Cloud Event. Does that need to be added as well?

@mtraver Do we need to support data_base64? I see that is a field supported in Python that we are not currently supporting in PHP

@mtraver also, in the links you provided, I'm not seeing support for the legacy event fields resource, eventType, eventId, or timestamp

Probably because cloudevents SDK doesn't cover legacy events, that should be handled in the functions framework...