knative/func

Signature adjustment for golang cloudevent handler ?

matzew opened this issue · 3 comments

Looking at the Go Lambda sdk, I see these rules for their handlers:

//   - handler must be a function
//   - handler may take between 0 and two arguments.
//   - if there are two arguments, the first argument must satisfy the "context.Context" interface.
//   - handler may return between 0 and two values.
//   - if there are two return values, the second return value must be an error.
//   - if there is one return value it must be an error.

this seems reasonable to me, while ours can be different. We allow also between 0 and 2 arg, but we also do not care if just one arg, the type is either context or the event.

Should we adjust these rules?

For the http we also have a different one:

but that's a bit different, so I think I am more wondering about the cloud events case

This seems worth considering. While I have commented on the "why" of the http handler being different, this one seems more open to mutation. I'll add this to the roadmap as something ready to work on, so we can discuss it when you've reached that part of the CloudEvent Scaffolding updates.

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.