Function Signatures
Comparison of different function signatures
There’re three function signatures in OpenFunction: HTTP
, CloudEvent
, and OpenFunction
. Let’s explain this in more detail using Go function as an example.
HTTP
and CloudEvent
signatures can be used to create sync functions while OpenFunction
signature can be used to create both sync and async functions.
Further more OpenFunction
signature can utilize various Dapr building blocks including Bindings, Pub/sub etc to access various BaaS services that helps to create more powerful functions. (Dapr State management, Configuration will be supported soon)
HTTP | CloudEvent | OpenFunction | |
---|---|---|---|
Signature | func(http.ResponseWriter, *http.Request) error | func(context.Context, cloudevents.Event) error | func(ofctx.Context, []byte) (ofctx.Out, error) |
Sync Functions | Supported | Supported | Supported |
Async Functions | Not supported | Not supported | Supported |
Dapr Binding | Not supported | Not supported | Supported |
Dapr Pub/sub | Not supported | Not supported | Supported |
Samples
As you can see, OpenFunction
signature is the recommended function signature, and we’re working on supporting this function signature in more language runtimes.