Function Signatures

Comparison of different function signatures

There’re three function signatures in OpenFunction: HTTP Functions, CloudEvent Functions, and OpenFunction Functions. Let’s explain this in more detail using Go function signature as an example.

HTTP Functions and CloudEvent Functions can be used to create sync functions while OpenFunction Functions can be used to create both sync and async functions.

Further more OpenFunction Functions can utilize various Dapr building blocks including Bindings, Pub/sub etc. to create more powerful functions. (Dapr State management, Configuration will be supported soon)

HTTP FunctionsCloudEvent FunctionsOpenFunction Functions
Signaturefunc(http.ResponseWriter, *http.Request) errorfunc(context.Context, cloudevents.Event) errorfunc(ofctx.Context, []byte) (ofctx.Out, error)
Sync FunctionsSupportedSupportedSupported
Async FunctionsNot supportedNot supportedSupported
Dapr BindingNot supportedNot supportedSupported
Dapr Pub/subNot supportedNot supportedSupported

Samples

As you can see, OpenFunction Functions is the recommended function signature, and we’re working on supporting this function signature in more language runtimes.

HTTP FunctionsCloudEvent FunctionsOpenFunction Functions
GoHello World, Multi-functions, log processingSync function with output binding, Kafka input & HTTP output binding, Cron input & Kafka output binding, Cron input binding, Kafka input binding, Kafka pubsub
NodejsHello WorldSync function with output binding, MQTT binding & pubsub
PythonHello World
JavaHello World
DotNetHello World

Last modified June 19, 2022: Adjust Capital (#111) (fd2e4cc)