Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c722869

Browse files
authoredJun 14, 2023
Merge pull request #16 from wanjunlei/master
release 1.2.0
2 parents 0b5586e + 4340417 commit c722869

File tree

10 files changed

+62
-155
lines changed

10 files changed

+62
-155
lines changed
 

‎CHANGLOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.2.0 / 2023-06-14
2+
3+
### Features
4+
5+
- Add support for OpenFunction v1beta2 API [#15](https://github.com/OpenFunction/functions-framework-java/pull/15).
6+
17
## 1.1.0 / 2023-06-01
28

39
### Features

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ that supports Maven to create the Maven project. Add this dependency in the
1313
<dependency>
1414
<groupId>dev.openfunction.functions</groupId>
1515
<artifactId>functions-framework-api</artifactId>
16-
<version>1.0.0</version>
16+
<version>1.2.0</version>
1717
</dependency>
1818
</dependencies>
1919
```
@@ -23,7 +23,7 @@ Framework dependency in your `build.gradle` project file as follows:
2323

2424
```groovy
2525
dependencies {
26-
implementation 'dev.openfunction.functions:functions-framework-api:1.0.0'
26+
implementation 'dev.openfunction.functions:functions-framework-api:1.2.0'
2727
}
2828
2929
```

‎functions-framework-invoker/src/main/java/dev/openfunction/invoker/context/RuntimeContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public boolean hasDaprTrigger() {
187187
return true;
188188
}
189189

190-
return functionContext.getTriggers() != null && ArrayUtils.isEmpty(functionContext.getTriggers().getDapr());
190+
return functionContext.getTriggers() != null && ArrayUtils.isNotEmpty(functionContext.getTriggers().getDapr());
191191
}
192192

193193
public Map<String, Component> getDaprTrigger() {

‎samples/src/main/java/dev/openfunction/samples/hooks/ExampleHook.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public Hook init() {
4545
public Error execute(Context ctx) {
4646
String ts = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.XXX").format(new Date());
4747
if (ctx.getBindingEvent() != null) {
48-
System.out.printf("hook %s:%s exec for binding %s at %s, seq %d, function %s", name(), version(), ctx.getBindingEvent().getName(), ts, seq, ctx.getName()).println();
48+
System.out.printf("hook %s:%s exec for binding %s at %s, seq %d", name(), version(), ctx.getBindingEvent().getName(), ts, seq).println();
4949
} else if (ctx.getTopicEvent() != null) {
50-
System.out.printf("hook %s:%s exec for pubsub %s at %s, seq %d, function %s", name(), version(), ctx.getTopicEvent().getName(), ts, seq, ctx.getName()).println();
50+
System.out.printf("hook %s:%s exec for pubsub %s at %s, seq %d", name(), version(), ctx.getTopicEvent().getName(), ts, seq).println();
5151
} else if (ctx.getHttpRequest() != null) {
5252
if (ctx.getCloudEvent() != null) {
53-
System.out.printf("hook %s:%s exec for cloudevent function %s at %s, seq %d", name(), version(), ctx.getName(), ts, seq).println();
53+
System.out.printf("hook %s:%s exec for cloudevent function at %s, seq %d", name(), version(), ts, seq).println();
5454
} else {
55-
System.out.printf("hook %s:%s exec for http function %s at %s, seq %d", name(), version(), ctx.getName(), ts, seq).println();
55+
System.out.printf("hook %s:%s exec for http function at %s, seq %d", name(), version(), ts, seq).println();
5656
}
5757
} else {
5858
System.out.println("unknown function type");

‎samples/src/main/java/dev/openfunction/samples/plugins/ExamplePlugin.java

Lines changed: 0 additions & 88 deletions
This file was deleted.

‎samples/src/main/resources/function/binding-function.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ apiVersion: core.openfunction.io/v1beta1
22
kind: Function
33
metadata:
44
name: cron-input-kafka-output
5-
annotations:
6-
plugins: |
7-
pre:
8-
- dev.openfunction.samples.plugins.ExamplePlugin
9-
post:
10-
- dev.openfunction.samples.plugins.ExamplePlugin
115
spec:
126
version: "v2.0.0"
137
image: openfunctiondev/cron-input-kafka-output-java:v1
@@ -27,13 +21,9 @@ spec:
2721
containers:
2822
- name: function # DO NOT change this
2923
imagePullPolicy: IfNotPresent
30-
runtime: "async"
31-
inputs:
32-
- name: cron
33-
component: cron
3424
outputs:
35-
- name: sample
36-
component: kafka-server
25+
- name: kafka-server
26+
type: bindings.kafka
3727
operation: "create"
3828
bindings:
3929
cron:
@@ -56,3 +46,12 @@ spec:
5646
value: "sample-topic"
5747
- name: authRequired
5848
value: "false"
49+
triggers:
50+
dapr:
51+
- name: cron
52+
type: bindings.cron
53+
hooks:
54+
post:
55+
- dev.openfunction.samples.hooks.ExampleHook
56+
pre:
57+
- dev.openfunction.samples.hooks.ExampleHook
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
apiVersion: core.openfunction.io/v1beta1
1+
apiVersion: core.openfunction.io/v1beta2
22
kind: Function
33
metadata:
44
name: function-cloudevent
5-
annotations:
6-
plugins: |
7-
pre:
8-
- dev.openfunction.samples.plugins.ExamplePlugin
9-
post:
10-
- dev.openfunction.samples.plugins.ExamplePlugin
115
spec:
126
version: "v2.0.0"
137
image: "openfunctiondev/function-cloudevent-java:v1"
148
imageCredentials:
159
name: push-secret
16-
port: 8080 # default to 8080
1710
build:
1811
builder: openfunctiondev/builder-java:v2-18
1912
env:
@@ -28,4 +21,8 @@ spec:
2821
containers:
2922
- name: function # DO NOT change this
3023
imagePullPolicy: IfNotPresent
31-
runtime: "knative"
24+
hooks:
25+
post:
26+
- dev.openfunction.samples.hooks.ExampleHook
27+
pre:
28+
- dev.openfunction.samples.hooks.ExampleHook
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
apiVersion: core.openfunction.io/v1beta1
1+
apiVersion: core.openfunction.io/v1beta2
22
kind: Function
33
metadata:
44
name: function-sample
5-
annotations:
6-
plugins: |
7-
pre:
8-
- dev.openfunction.samples.plugins.ExamplePlugin
9-
post:
10-
- dev.openfunction.samples.plugins.ExamplePlugin
115
spec:
126
version: "v2.0.0"
137
image: "openfunctiondev/sample-go-func-java:v1"
148
imageCredentials:
159
name: push-secret
16-
port: 8080 # default to 8080
1710
build:
1811
builder: openfunctiondev/builder-java:v2-17
1912
env:
@@ -28,4 +21,8 @@ spec:
2821
containers:
2922
- name: function # DO NOT change this
3023
imagePullPolicy: IfNotPresent
31-
runtime: "knative"
24+
hooks:
25+
post:
26+
- dev.openfunction.samples.hooks.ExampleHook
27+
pre:
28+
- dev.openfunction.samples.hooks.ExampleHook

‎samples/src/main/resources/function/http-with-output.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
apiVersion: core.openfunction.io/v1beta1
1+
apiVersion: core.openfunction.io/v1beta2
22
kind: Function
33
metadata:
44
name: http-with-output
5-
annotations:
6-
plugins: |
7-
pre:
8-
- dev.openfunction.samples.plugins.ExamplePlugin
9-
post:
10-
- dev.openfunction.samples.plugins.ExamplePlugin
115
spec:
126
version: "v2.0.0"
137
image: "openfunctiondev/http-with-output-java:v1"
148
imageCredentials:
159
name: push-secret
16-
port: 8080 # default to 8080
1710
build:
1811
builder: openfunctiondev/builder-java:v2-17
1912
env:
@@ -28,10 +21,9 @@ spec:
2821
containers:
2922
- name: function # DO NOT change this
3023
imagePullPolicy: IfNotPresent
31-
runtime: "knative"
3224
outputs:
33-
- name: sample
34-
component: kafka-server
25+
- name: kafka-server
26+
type: bindings.kafka
3527
operation: "create"
3628
bindings:
3729
kafka-server:
@@ -48,3 +40,8 @@ spec:
4840
value: "sample-topic"
4941
- name: authRequired
5042
value: "false"
43+
hooks:
44+
post:
45+
- dev.openfunction.samples.hooks.ExampleHook
46+
pre:
47+
- dev.openfunction.samples.hooks.ExampleHook

‎samples/src/main/resources/function/subcreibe-function.yaml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
apiVersion: core.openfunction.io/v1beta1
1+
apiVersion: core.openfunction.io/v1beta2
22
kind: Function
33
metadata:
4-
annotations:
5-
plugins: |
6-
pre:
7-
- dev.openfunction.samples.plugins.ExamplePlugin
8-
post:
9-
- dev.openfunction.samples.plugins.ExamplePlugin
104
name: autoscaling-subscriber
115
spec:
126
version: "v2.0.0"
@@ -25,9 +19,15 @@ spec:
2519
sourceSubPath: "samples"
2620
revision: "java"
2721
serving:
28-
runtime: "async"
2922
scaleOptions:
3023
keda:
24+
triggers:
25+
- type: kafka
26+
metadata:
27+
topic: "sample-topic"
28+
bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092
29+
consumerGroup: autoscaling-subscriber
30+
lagThreshold: "20"
3131
scaledObject:
3232
pollingInterval: 15
3333
minReplicaCount: 0
@@ -44,21 +44,10 @@ spec:
4444
periodSeconds: 15
4545
scaleUp:
4646
stabilizationWindowSeconds: 0
47-
triggers:
48-
- type: kafka
49-
metadata:
50-
topic: "sample-topic"
51-
bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092
52-
consumerGroup: autoscaling-subscriber
53-
lagThreshold: "20"
5447
template:
5548
containers:
5649
- name: function # DO NOT change this
5750
imagePullPolicy: IfNotPresent
58-
inputs:
59-
- name: producer
60-
component: kafka-server
61-
topic: "sample-topic"
6251
pubsub:
6352
kafka-server:
6453
type: pubsub.kafka
@@ -72,3 +61,13 @@ spec:
7261
value: "sample-topic"
7362
- name: consumerID
7463
value: "autoscaling-subscriber"
64+
triggers:
65+
dapr:
66+
- name: kafka-server
67+
type: bindings.cron
68+
topic: "sample-topic"
69+
hooks:
70+
post:
71+
- dev.openfunction.samples.hooks.ExampleHook
72+
pre:
73+
- dev.openfunction.samples.hooks.ExampleHook

0 commit comments

Comments
 (0)