func icon indicating copy to clipboard operation
func copied to clipboard

Signature adjustment for golang cloudevent handler ?

Open matzew opened this issue 2 years ago • 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?

matzew avatar Dec 14 '23 06:12 matzew

For the http we also have a different one:

  • https://github.com/knative/func/blob/main/templates/go/http/handle.go#L11

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

matzew avatar Dec 14 '23 06:12 matzew

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.

lkingland avatar Jan 09 '24 13:01 lkingland

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.

github-actions[bot] avatar Apr 09 '24 01:04 github-actions[bot]