File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ apiVersion : core.openfunction.io/v1beta1
2+ kind : Function
3+ metadata :
4+ name : sample-node-async-bindings
5+ spec :
6+ version : v2.0.0
7+ image : your-docker-registry/image:tag
8+ # imageCredentials:
9+ # name: your-docker-registry-secret
10+ # build:
11+ # builder: openfunction/builder-node:v2-16.13
12+ # env:
13+ # FUNC_NAME: tryKnative
14+ # srcRepo:
15+ # url: https://github.com/OpenFunction/samples.git
16+ # sourceSubPath: functions/node/src
17+ # revision: main
18+ # app port default to "8080"
19+ # port: 8080
20+ serving :
21+ # default to knative
22+ runtime : async
23+ annotations :
24+ # Dapr annotations: https://docs.dapr.io/reference/arguments-annotations-overview/
25+ # default to "grpc"
26+ dapr.io/app-protocol : http
27+ # default to "info"
28+ dapr.io/log-level : debug
29+ # default to "true"
30+ dapr.io/log-as-json : ' false'
31+ template :
32+ containers :
33+ - name : function
34+ imagePullPolicy : Always
35+ params :
36+ # default to FUNC_NAME value
37+ FUNCTION_TARGET : tryAsync
38+ DEBUG : common:*,ofn:*
39+ inputs :
40+ - name : mqtt-input
41+ component : mqtt-in
42+ outputs :
43+ - name : mqtt-output
44+ component : mqtt-out
45+ operation : create
46+ bindings :
47+ # Dapr MQTT Binding: https://docs.dapr.io/reference/components-reference/supported-bindings/mqtt/
48+ mqtt-in :
49+ type : bindings.mqtt
50+ version : v1
51+ metadata :
52+ - name : consumerID
53+ value : ' {uuid}'
54+ - name : url
55+ value : tcp://admin:public@emqx:1883
56+ - name : topic
57+ value : in
58+ mqtt-out :
59+ type : bindings.mqtt
60+ version : v1
61+ metadata :
62+ - name : consumerID
63+ value : ' {uuid}'
64+ - name : url
65+ value : tcp://admin:public@emqx:1883
66+ - name : topic
67+ value : out
Original file line number Diff line number Diff line change 1+ apiVersion : core.openfunction.io/v1beta1
2+ kind : Function
3+ metadata :
4+ name : sample-node-async-pubsub
5+ spec :
6+ version : v2.0.0
7+ image : your-docker-registry/image:tag
8+ # imageCredentials:
9+ # name: your-docker-registry-secret
10+ # build:
11+ # builder: openfunction/builder-node:v2-16.13
12+ # env:
13+ # FUNC_NAME: tryKnative
14+ # srcRepo:
15+ # url: https://github.com/OpenFunction/samples.git
16+ # sourceSubPath: functions/node/src
17+ # revision: main
18+ # app port default to "8080"
19+ # port: 8080
20+ serving :
21+ # default to knative
22+ runtime : async
23+ annotations :
24+ # Dapr annotations: https://docs.dapr.io/reference/arguments-annotations-overview/
25+ # default to "grpc"
26+ dapr.io/app-protocol : http
27+ # default to "info"
28+ dapr.io/log-level : debug
29+ # default to "true"
30+ dapr.io/log-as-json : ' false'
31+ template :
32+ containers :
33+ - name : function
34+ imagePullPolicy : Always
35+ params :
36+ # default to FUNC_NAME value
37+ FUNCTION_TARGET : tryAsync
38+ DEBUG : common:*,ofn:*
39+ inputs :
40+ - name : mqtt-sub
41+ component : mqtt-pubsub
42+ topic : sub
43+ outputs :
44+ - name : mqtt-pub
45+ component : mqtt-pubsub
46+ topic : pub
47+ pubsub :
48+ # Dapr MQTT PubSub: https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-mqtt/
49+ mqtt-pubsub :
50+ type : pubsub.mqtt
51+ version : v1
52+ metadata :
53+ - name : consumerID
54+ value : ' {uuid}'
55+ - name : url
56+ value : tcp://admin:public@emqx:1883
57+ - name : qos
58+ value : 1
Original file line number Diff line number Diff line change 1+ apiVersion : core.openfunction.io/v1beta1
2+ kind : Function
3+ metadata :
4+ name : sample-node-knative
5+ spec :
6+ version : v2.0.0
7+ image : your-docker-registry/image:tag
8+ # imageCredentials:
9+ # name: your-docker-registry-secret
10+ # build:
11+ # builder: openfunction/builder-node:v2-16.13
12+ # env:
13+ # FUNC_NAME: tryKnative
14+ # srcRepo:
15+ # url: https://github.com/OpenFunction/samples.git
16+ # sourceSubPath: functions/node/src
17+ # revision: main
18+ # app port default to "8080"
19+ # port: 8080
20+ serving :
21+ runtime : knative
22+ scaleOptions :
23+ minReplicas : 0
24+ maxReplicas : 2
25+ template :
26+ containers :
27+ - name : function
28+ imagePullPolicy : Always
29+ params :
30+ # default to "production"
31+ NODE_ENV : dev
32+ # Node.js debug wildcards
33+ DEBUG : common:*,ofn:*
Original file line number Diff line number Diff line change 1+ export const tryKnative = ( req , res ) => {
2+ res . send ( `Hello, ${ req . query . u || 'World' } !` ) ;
3+ } ;
4+
5+ export const tryAsync = ( ctx , data ) => {
6+ console . log ( 'Data received: %o' , data ) ;
7+ ctx . send ( data ) ;
8+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "main" : " index.mjs" ,
3+ "scripts" : {
4+ "start" : " functions-framework --target=tryKnative"
5+ },
6+ "dependencies" : {
7+ "@openfunction/functions-framework" : " ^0.4.1"
8+ }
9+ }
You can’t perform that action at this time.
0 commit comments