You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We'd love to accept your patches and contributions to this project. There are
4
-
just a few small guidelines you need to follow.
3
+
We'd love to accept your patches and contributions to this project. There are a few small guidelines you need to follow.
5
4
6
5
## Contributor License Agreement
7
6
8
-
Contributions to this project must be accompanied by a Contributor License
9
-
Agreement. You (or your employer) retain the copyright to your contribution;
10
-
this simply gives us permission to use and redistribute your contributions as
11
-
part of the project. Head over to <https://cla.developers.google.com/> to see
12
-
your current agreements on file or to sign a new one.
7
+
Contributions to this project must be accompanied by a Developer Certificate of Origin (DCO). You (or your employer) retain the copyright to your contribution; this gives us permission to use and redistribute your contributions as part of the project. Head over to <https://developercertificate.org/> to see your current agreements on file or to sign a new one.
13
8
14
-
You generally only need to submit a CLA once, so if you've already submitted one
15
-
(even if it was for a different project), you probably don't need to do it
16
-
again.
9
+
You only need to submit a DTO once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.
17
10
18
11
## Code reviews
19
12
20
-
All submissions, including submissions by project members, require review. We
21
-
use GitHub pull requests for this purpose. Consult
22
-
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23
-
information on using pull requests.
13
+
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more information on using pull requests.
24
14
25
15
## Testing
26
16
27
17
### Unit Tests
28
18
29
19
All pull requests should have an associated test to ensure foward compatibility.
30
20
21
+
> Make sure you have installed [Dapr](https://dapr.io/) before running unit tests, check out [Install Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/) for more details
22
+
31
23
To run an individual test, you can run a command such as the following:
32
24
33
-
```
25
+
```sh
34
26
npm run test -- -g 'loading function'
35
27
```
36
28
37
-
### Conformance Tests
38
-
39
-
To run the conformance tests, first install Go 1.16+, then run the tests:
40
-
41
-
```
42
-
npm run conformance
43
-
```
44
-
45
29
### Manual Testing
46
30
47
-
When developing a feature locally, you can install a local version of the Functions Framework
48
-
using `npm link`. First compile your local clone of the Functions Framework:
31
+
When developing a feature locally, you can install a local version of the Functions Framework using `npm link`. First compile your local clone of the Functions Framework:
49
32
50
33
> You'll need to install typescript first by: `npm install typescript --save-dev`
51
34
52
-
```
35
+
```sh
53
36
npx tsc
54
37
```
55
38
56
39
Then link the Functions Framework using `npm link`.
57
40
58
-
```
41
+
```sh
59
42
npm link
60
43
```
61
44
@@ -65,14 +48,15 @@ You can then run the Functions Framework locally using `functions-framework`.
65
48
66
49
This module is published using Release Please. When you merge a release PR, the npm package will be automatically published.
67
50
68
-
```shell
51
+
```sh
69
52
# Login to npm registry, contact repo admin for https://www.npmjs.com/ user name and password
70
53
npm login
71
54
# First run a dry run to find out errors
72
55
npm publish ./ --access public --dry-run
73
56
# Then publish the package
74
57
npm publish --access public
75
58
```
59
+
76
60
### Reverting a Publish
77
61
78
62
If the release process fails, you can revert the publish by running the following (i.e. unpublishing `1.10.0`):
@@ -101,5 +85,4 @@ The docs will be generated in [`docs/generated/`](docs/generated/).
101
85
102
86
## Community Guidelines
103
87
104
-
This project follows [Google's Open Source Community
| `--port` | `PORT` | The port on which the Functions Framework listens for requests. Default: `8080` |
170
170
| `--target` | `FUNCTION_TARGET` | The name of the exported function to be invoked in response to requests. Default: `function` |
171
-
| `--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` or `cloudevent` |
171
+
| `--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` or `cloudevent` or `openfunction` |
172
172
| `--source` | `FUNCTION_SOURCE` | The path to the directory of your function. Default: `cwd` (thecurrentworkingdirectory) |
173
173
174
174
You can set command-line flags in your `package.json` via the `start` script.
@@ -196,7 +196,52 @@ Dapr bindings allows you to trigger your applications or services with events co
196
196
197
197
Asynchronous function introduces Dapr pub/sub to provide a platform-agnostic API to send and receive messages. A typical use case is that you can leverage synchronous functions to receive an event in plain JSON or Cloud Events format, and then send the received event to a Dapr output binding or pub/sub component, most likely a message queue (e.g. Kafka, NATS Streaming, GCP PubSub, MQTT). Finally, the asynchronous function could be triggered from the message queue.
198
198
199
-
More details would be brought up to you in some quickstart samples, stay tuned.
199
+
Async function use below function signature which is quite difference from that of Express style sync function:
* `ctx.send(payload, output?)`: Send `payload` to all or one specific `output` of Dapr Output [Binding](https://docs.dapr.io/reference/components-reference/supported-bindings/) or Pub [Broker](https://docs.dapr.io/reference/components-reference/supported-pubsub/)
207
+
* Notice that `ctx.send` CAN be invoked where necessary, when you have certain outgoing data to send
208
+
* `data`: Data recieved from Dapr Input Binding or Sub Broker
209
+
210
+
For more details about async function and demo, please check out our [Node.js Async Function Quickstart](https://openfunction-talks.netlify.app/2022/202-node-async/).
211
+
212
+
#### HTTP Trigger Async Function
213
+
214
+
Sync functions is triggered by HTTP request, so Dapr is not used in sync function input. Whenever there are functions output requirements, sync functions can also send output to Dapr output binding or pubsub components.
215
+
216
+
Here is another function sample:
217
+
218
+
* Users send a HTTP request to a [Knative Sync function](https://github.com/OpenFunction/samples/tree/main/functions/knative/with-output-binding).
219
+
* This sync function handles the request and then send its output to Kafka through a Dapr Kafka output binding or pubsub component.
220
+
* An [async function](https://github.com/OpenFunction/samples/tree/main/functions/async/bindings/kafka-input) is then triggered by this output event in Kafka (through a Dapr Kafka input binding or pubsub component)
0 commit comments