File tree Expand file tree Collapse file tree
functions/knative/with-output-binding-node 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-http-trigger
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/async/mqtt-io-node
17+ # revision: main
18+ # app port default to "8080"
19+ # port: 8080
20+ serving :
21+ # default to knative
22+ runtime : knative
23+ scaleOptions :
24+ minReplicas : 0
25+ maxReplicas : 2
26+ annotations :
27+ # Dapr annotations: https://docs.dapr.io/reference/arguments-annotations-overview/
28+ # default to "info"
29+ dapr.io/log-level : debug
30+ # default to "true"
31+ dapr.io/log-as-json : ' false'
32+ template :
33+ containers :
34+ - name : function
35+ imagePullPolicy : Always
36+ params :
37+ # default to FUNC_NAME value
38+ FUNCTION_TARGET : tryKnativeAsync
39+ # default to http
40+ FUNCTION_SIGNATURE_TYPE : openfunction
41+ DEBUG : common:*,ofn:*
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-out :
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 : out
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 tryKnativeAsync = async ( ctx , data ) => {
6+ console . log ( 'Data received: %o' , data ) ;
7+ await ctx . send ( data ) ;
8+
9+ // Optional to send ANY data back as HTTP response
10+ // Request data is also accessible via "ctx.req"
11+ // ctx.res.send(ctx.req.query);
12+ } ;
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.5.0"
8+ }
9+ }
You can’t perform that action at this time.
0 commit comments