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)

HTTPCloudEventOpenFunction
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 signature is the recommended function signature, and we’re working on supporting this function signature in more language runtimes.

HTTPCloudEventOpenFunction
GoHello World, Multi-functions, Sync function with path parameters, log processingSync function with path parametersSync function with path parameters, Sync 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 WorldCloudEventSync function with output, Cron input & Kafka output binding, Kafka pubsub
DotNetHello World