Skip to content

Latest commit

 

History

History
139 lines (105 loc) · 8.98 KB

OpenFunction-context-specs.md

File metadata and controls

139 lines (105 loc) · 8.98 KB

OpenFunction Context Specs

Overview

Statement

Scope indicates which functions-framework has already support this item.

functions-framework abbreviation

OpenFunction/functions-framework-go -> ff-go

OpenFunction/functions-framework-nodejs -> ff-js

Context

Example:

{
  "name": "function",
  "version": "v1",
  "requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01",
  "port": "50002",
  "clientPort": "44538",
  "inputs": {},
  "outputs": {},
  "runtime": "OpenFuncAsync",
  "state": ""
}

Specification:

Key Type Description Scope example
name string, require Function name. ff-go "myfunction", "hello-func"
version string, require Function version. ff-go "v1", "v2"
requestID string Request ID, uuid format. ff-go "a0f2ad8d-5062-4812-91e9-95416489fb01"
port string Function serving port. ff-go "50001"
clientPort string Dapr client port. ff-go "44544"
inputs map Function input from bindings data.
A map of Input objects. The key is the name of input and the value is input object, see Input.
Empty means no input.
ff-go
outputs map Function output to bindings data.
A map of Output objects. The key is the name of output and the value is output object, see Output.
Empty means no output.
ff-go
runtime enum, require Function serving runtime, see Runtime. ff-go "Knative", "OpenFuncAsync"
state string Used to store the states of the function in operation.

Input

Example:

{
  "my-input": {
    "uri": "my-uri",
    "Component": "my-component",
    "type": "bindings",
    "metadata": {
      "Content-Type": "application/json; charset=utf-8"
    }
  }
}

Specification:

Key Type Description Scope example
name(key) string Input name. ff-go "demo-kafka", "cron-job"
uri string Input serving listening path. This indicates the destination of the input data.
Bindings: same as the component's name, can be omitted.
Pubsub: represent the topic's name, cannot be omitted.
ff-go "echo"
type string Input type. When using OpenFuncAsync as runtime, you need to set the type (refer to Input Type) parameter. ff-go "bindings"
component string The component's name. ff-go "componentA"
metadata map The metadata to be passed to dapr for use. Usage can be found in dapr's documentation. ff-go

Input Type

Effective only when using OpenFuncAsync as runtime.

Value Description Scope
bindings Indicates that the input is the Dapr bindings component. Refer to Bindings API reference to learn more about Dapr bindings components. ff-go
pubsub Indicates that the input is the Dapr pubsub component. Refer to Pub/sub API reference to learn more about Dapr bindings components.
❗Note that when using pubsub as input, the name of pubsub's topic should be assigned to the input's uri.
ff-go

Outputs

Examples:

{
  "my-output": {
    "uri": "my-uri",
    "Component": "my-component",
    "type": "bindings",
    "operation": "post"
  }
}

Specification:

Output

Key Type Description Scope example
name(key) string Output name. ff-go "demo-kafka", "cron-job"
uri string Output serving listening path. This indicates the destination of the output data.
Bindings: same as the component's name, can be omitted.
Pubsub: represent the topic's name, cannot be omitted.
ff-go "echo"
type string Output type. When using OpenFuncAsync as runtime, you need to set the type (refer to Output Type) parameter. ff-go "bindings"
component string The component's name. ff-go "componentA"
metadata map The metadata to be passed to dapr for use. Usage can be found in dapr's documentation. ff-go
operation string The operation's name. Usage can be found in dapr's documentation. ff-go "post", "create"
Output Type

Effective only when using OpenFuncAsync as runtime.

Value Description Scope
bindings Indicates that the output is the Dapr bindings component. Refer to Bindings API reference to learn more about Dapr bindings components. ff-go
pubsub Indicates that the output is the Dapr pubsub component. Refer to Pub/sub API reference to learn more about Dapr bindings components.
❗Note that when using pubsub as output, the name of pubsub's topic should be assigned to the output's uri.
ff-go

Runtime

We currently support Knative and OpenFuncAsync serving runtime.

Value Description Scope
Knative Serving function with Knative runtime (based on Knative). ff-go
OpenFuncAsync Serving function with OpenFuncAsync runtime (based on KEDA+Dapr). ff-go