Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e432afa

Browse files
author
Benjamin Huo
authored
Merge pull request #3 from tpiperatgod/dev
Update the specification of OpenFunction Context
2 parents 30524e2 + 78e4e8b commit e432afa

File tree

2 files changed

+73
-49
lines changed

2 files changed

+73
-49
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OpenFunction Functions Framework is designed to provide users of FaaS with a sui
1212
### Runtime
1313

1414
- Knative
15-
- KEDA + Dapr
15+
- OpenFuncAsync
1616

1717
### Function Type
1818

@@ -37,4 +37,3 @@ OpenFunction Functions Framework is designed to provide users of FaaS with a sui
3737
## Contributing
3838

3939
You can get help on developing OpenFunction Functions Framework by visiting [CONTRIBUTING](CONTRIBUTING.md) .
40-

docs/OpenFunction-context-specs.md

Lines changed: 72 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,91 +12,116 @@ OpenFunction/functions-framework-go -> ff-go
1212

1313
## Context
1414

15+
Example:
16+
17+
```json
18+
{
19+
"name": "function",
20+
"version": "v1",
21+
"requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01",
22+
"port": "50002",
23+
"input": {},
24+
"outputs": {},
25+
"runtime": "OpenFuncAsync",
26+
"state": ""
27+
}
28+
```
29+
30+
Specification:
31+
1532
| Key | Type | Description | Scope | example |
1633
| ---------- | --------------- | --------------------------------------------------------- | ------------------------------------------------------------ | -------------------------------------- |
17-
| name | string, require | Function name | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "myfunction", "hello-func" |
18-
| version | string, require | Function version | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "v1", "v2" |
19-
| request_id | string | Request ID, uuid format | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "a0f2ad8d-5062-4812-91e9-95416489fb01" |
20-
| protocol | enum, require | Function serving kind, see [Protocol](#protocol) | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "gRPC", "HTTP" |
21-
| port | string, require | Function serving port | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "8080", "50001" |
22-
| input | object | Function input from bindings data, see [Input](#input) | [ff-go](https://github.com/OpenFunction/functions-framework-go) | |
23-
| outputs | object | Function output to bindings data, see [Outputs](#outputs) | [ff-go](https://github.com/OpenFunction/functions-framework-go) | |
24-
| runtime | enum, require | Function serving runtime, see [Runtime](#runtime) | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "Knative", "Dapr" |
25-
| state | string | Used to store the states of the function in operation | | |
26-
27-
### Protocol
34+
| name | string, require | Function name. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "myfunction", "hello-func" |
35+
| version | string, require | Function version. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "v1", "v2" |
36+
| requestID | string | Request ID, uuid format. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "a0f2ad8d-5062-4812-91e9-95416489fb01" |
37+
| port | string, require | Function serving port. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "50001" |
38+
| input | object | Function input from bindings data, see [Input](#input). Empty means no input. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | |
39+
| outputs | map | Function output to bindings data. <br />A map of Output objects. The key is the name of output. When using OpenFuncAsync as runtime, this name needs to be consistent with the corresponding Dapr component resource name. Refer to [this docs](https://docs.dapr.io/concepts/components-concept/) to learn about Dapr components. <br />The value is output object, see [Output](#output). Empty means no output. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | |
40+
| runtime | enum, require | Function serving runtime, see [Runtime](#runtime). | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "Knative", "OpenFuncAsync" |
41+
| state | string | Used to store the states of the function in operation. | | |
2842

29-
We currently support `HTTP` and `gRPC` protocol modes.
43+
### Input
3044

31-
| Value | Description | Scope |
32-
| ----- | ----------------------------------- | ------------------------------------------------------------ |
33-
| HTTP | Serving function with HTTP protocol | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
34-
| gRPC | Serving function with gRPC protocol | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
45+
Example:
3546

36-
<div align="right">
37-
<b><a href="#context">↥ back to Context</a></b>
38-
</div>
47+
```json
48+
{
49+
"name": "my_input",
50+
"uri": "my_topic",
51+
"params": {
52+
"type": "pubsub"
53+
}
54+
}
55+
```
3956

40-
### Input
57+
Specification:
4158

4259
| Key | Type | Description | Scope | example |
4360
| ---------- | ------ | ------------------------------------------------------------ | -------------------------------------- | -------------------------------------- |
44-
| name | string | Input name. When using Dapr as runtime, this name needs to be consistent with the corresponding Dapr component resource name. Refer to [this docs](https://docs.dapr.io/concepts/components-concept/) to learn about Dapr components. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "demo-kafka", "cron-job" |
45-
| enable | bool, require | Switch of input | [ff-go](https://github.com/OpenFunction/functions-framework-go) | true, false |
46-
| pattern | string | Input serving listening path. For HTTP functions, it can be set to "/somepath" while "somepath" for gRPC functions. This indicates the destination of the input data. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "echo", "/echo" |
47-
| in_type | enum | Input type. Effective only when using Dapr as runtime. See [InType](#intype) | [ff-go](https://github.com/OpenFunction/functions-framework-go) | |
61+
| name | string | Input name. When using OpenFuncAsync as runtime, this name needs to be consistent with the corresponding Dapr component resource name. Refer to [this docs](https://docs.dapr.io/concepts/components-concept/) to learn about Dapr components. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "demo-kafka", "cron-job" |
62+
| uri | string | Input serving listening path. This indicates the destination of the input data. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "echo" |
63+
| params | map | Input params. When using OpenFuncAsync as runtime, you need to set the `type` (refer to [Input Type](#input-type)) parameter. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | {"type": "pubsub"} |
4864

49-
#### InType
65+
#### Input Type
5066

51-
Effective only when using Dapr as runtime.
67+
Effective only when using OpenFuncAsync as runtime.
5268

5369
| Value | Description | Scope |
5470
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
5571
| bindings | Indicates that the input is the Dapr bindings component. Refer to [Bindings API reference](https://docs.dapr.io/reference/api/bindings_api/) to learn more about Dapr bindings components. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
56-
| pubsub | Indicates that the input is the Dapr pubsub component. Refer to [Pub/sub API reference](https://docs.dapr.io/reference/api/pubsub_api/) to learn more about Dapr bindings components. <br />:heavy_exclamation_mark:Note that when using pubsub as input, the name of pubsub's topic should be assigned to the input's pattern. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
57-
| invoke | Indicates that the input is the Dapr service invocation component. Refer to [Service invocation API reference](https://docs.dapr.io/reference/api/service_invocation_api/) to learn more about Dapr bindings components.<br />:heavy_exclamation_mark:Note that when using invoke as input, the name of invoke method should be assigned to the input's pattern. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
72+
| pubsub | Indicates that the input is the Dapr pubsub component. Refer to [Pub/sub API reference](https://docs.dapr.io/reference/api/pubsub_api/) to learn more about Dapr bindings components. <br />:heavy_exclamation_mark:Note that when using pubsub as input, the name of pubsub's topic should be assigned to the input's uri. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
73+
| invoke | Indicates that the input is the Dapr service invocation component. Refer to [Service invocation API reference](https://docs.dapr.io/reference/api/service_invocation_api/) to learn more about Dapr bindings components.<br />:heavy_exclamation_mark:Note that when using invoke as input, the name of invoke method should be assigned to the input's uri. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
5874

5975
<div align="right">
6076
<b><a href="#context">↥ back to Context</a></b>
6177
</div>
62-
6378
### Outputs
6479

65-
| Key | Type | Description | Scope | example |
66-
| -------------- | ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ----------- |
67-
| enable | bool, require | Switch of outputs | [ff-go](https://github.com/OpenFunction/functions-framework-go) | true, false |
68-
| output_objects | map | A map of Output objects. <br />The key is the name of output. When using Dapr as runtime, this name needs to be consistent with the corresponding Dapr component resource name. Refer to [this docs](https://docs.dapr.io/concepts/components-concept/) to learn about Dapr components. <br />The value is output object, see [Output](#output) | [ff-go](https://github.com/OpenFunction/functions-framework-go) | |
80+
Examples:
81+
82+
```json
83+
{
84+
"my_output": {
85+
"uri": "print",
86+
"params": {
87+
"method": "post",
88+
"type": "invoke"
89+
}
90+
}
91+
}
92+
```
93+
94+
Specification:
6995

7096
#### Output
7197

72-
| Key | Type | Description | Scope | example |
73-
| -------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------- |
74-
| pattern | string | Output serving listening path. For HTTP functions, it can be set to "/somepath" while "somepath" for gRPC functions. This indicates the destination of the out data. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | true, false |
75-
| out_type | enum | Output type. Effective only when using Dapr as runtime. See [OutType](#outtype) | [ff-go](https://github.com/OpenFunction/functions-framework-go) | |
76-
| params | map | Used to store parameters when using output. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | {"method": "post"}, {"operation": "create"} |
98+
| Key | Type | Description | Scope | example |
99+
| ------ | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------- |
100+
| uri | string | Output serving listening path. This indicates the destination of the out data. | [ff-go](https://github.com/OpenFunction/functions-framework-go) | "echo" |
101+
| params | map | When using OpenFuncAsync as runtime, you need to set the `type` (refer to [Output Type](#output-type)) parameter. <br />You also need to set other relevant parameters according to [Dapr's docs](https://docs.dapr.io/reference/api/). | [ff-go](https://github.com/OpenFunction/functions-framework-go) | {"method": "post"}, {"operation": "create"} |
77102

78-
##### OutType
103+
##### Output Type
79104

80-
Effective only when using Dapr as runtime.
105+
Effective only when using OpenFuncAsync as runtime.
81106

82107
| Value | Description | Scope |
83108
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
84109
| bindings | Indicates that the output is the Dapr bindings component. Refer to [Bindings API reference](https://docs.dapr.io/reference/api/bindings_api/) to learn more about Dapr bindings components. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
85-
| pubsub | Indicates that the output is the Dapr pubsub component. Refer to [Pub/sub API reference](https://docs.dapr.io/reference/api/pubsub_api/) to learn more about Dapr bindings components. <br />:heavy_exclamation_mark:Note that when using pubsub as output, the name of pubsub's topic should be assigned to the output's pattern. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
86-
| invoke | Indicates that the output is the Dapr service invocation component. Refer to [Service invocation API reference](https://docs.dapr.io/reference/api/service_invocation_api/) to learn more about Dapr bindings components.<br />:heavy_exclamation_mark:Note that when using invoke as output, the name of invoke method should be assigned to the output's pattern. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
110+
| pubsub | Indicates that the output is the Dapr pubsub component. Refer to [Pub/sub API reference](https://docs.dapr.io/reference/api/pubsub_api/) to learn more about Dapr bindings components. <br />:heavy_exclamation_mark:Note that when using pubsub as output, the name of pubsub's topic should be assigned to the output's uri. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
111+
| invoke | Indicates that the output is the Dapr service invocation component. Refer to [Service invocation API reference](https://docs.dapr.io/reference/api/service_invocation_api/) to learn more about Dapr bindings components.<br />:heavy_exclamation_mark:Note that when using invoke as output, the name of invoke method should be assigned to the output's uri. | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
87112

88113
<div align="right">
89114
<b><a href="#context">↥ back to Context</a></b>
90115
</div>
91116

92117
### Runtime
93118

94-
We currently support `Knative` and `Dapr` serving runtime.
119+
We currently support `Knative` and `OpenFuncAsync` serving runtime.
95120

96-
| Value | Description | Scope |
97-
| ------- | ------------------------------------- | ------------------------------------------------------------ |
98-
| Knative | Serving function with Knative runtime | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
99-
| Dapr | Serving function with Dapr runtime | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
121+
| Value | Description | Scope |
122+
| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
123+
| Knative | Serving function with Knative runtime (based on Knative). | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
124+
| OpenFuncAsync | Serving function with OpenFuncAsync runtime (based on KEDA+Dapr). | [ff-go](https://github.com/OpenFunction/functions-framework-go) |
100125

101126
<div align="right">
102127
<b><a href="#context">↥ back to Context</a></b>

0 commit comments

Comments
 (0)