Skip to content

Commit

Permalink
release 1.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: wanjunlei <wanjunlei@kubesphere.io>
  • Loading branch information
wanjunlei committed Jun 14, 2023
1 parent 0b5586e commit 4340417
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 155 deletions.
6 changes: 6 additions & 0 deletions CHANGLOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.2.0 / 2023-06-14

### Features

- Add support for OpenFunction v1beta2 API [#15](https://github.com/OpenFunction/functions-framework-java/pull/15).

## 1.1.0 / 2023-06-01

### Features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ that supports Maven to create the Maven project. Add this dependency in the
<dependency>
<groupId>dev.openfunction.functions</groupId>
<artifactId>functions-framework-api</artifactId>
<version>1.0.0</version>
<version>1.2.0</version>
</dependency>
</dependencies>
```
Expand All @@ -23,7 +23,7 @@ Framework dependency in your `build.gradle` project file as follows:

```groovy
dependencies {
implementation 'dev.openfunction.functions:functions-framework-api:1.0.0'
implementation 'dev.openfunction.functions:functions-framework-api:1.2.0'
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public boolean hasDaprTrigger() {
return true;
}

return functionContext.getTriggers() != null && ArrayUtils.isEmpty(functionContext.getTriggers().getDapr());
return functionContext.getTriggers() != null && ArrayUtils.isNotEmpty(functionContext.getTriggers().getDapr());
}

public Map<String, Component> getDaprTrigger() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public Hook init() {
public Error execute(Context ctx) {
String ts = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.XXX").format(new Date());
if (ctx.getBindingEvent() != null) {
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();
System.out.printf("hook %s:%s exec for binding %s at %s, seq %d", name(), version(), ctx.getBindingEvent().getName(), ts, seq).println();
} else if (ctx.getTopicEvent() != null) {
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();
System.out.printf("hook %s:%s exec for pubsub %s at %s, seq %d", name(), version(), ctx.getTopicEvent().getName(), ts, seq).println();
} else if (ctx.getHttpRequest() != null) {
if (ctx.getCloudEvent() != null) {
System.out.printf("hook %s:%s exec for cloudevent function %s at %s, seq %d", name(), version(), ctx.getName(), ts, seq).println();
System.out.printf("hook %s:%s exec for cloudevent function at %s, seq %d", name(), version(), ts, seq).println();
} else {
System.out.printf("hook %s:%s exec for http function %s at %s, seq %d", name(), version(), ctx.getName(), ts, seq).println();
System.out.printf("hook %s:%s exec for http function at %s, seq %d", name(), version(), ts, seq).println();
}
} else {
System.out.println("unknown function type");
Expand Down

This file was deleted.

23 changes: 11 additions & 12 deletions samples/src/main/resources/function/binding-function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ apiVersion: core.openfunction.io/v1beta1
kind: Function
metadata:
name: cron-input-kafka-output
annotations:
plugins: |
pre:
- dev.openfunction.samples.plugins.ExamplePlugin
post:
- dev.openfunction.samples.plugins.ExamplePlugin
spec:
version: "v2.0.0"
image: openfunctiondev/cron-input-kafka-output-java:v1
Expand All @@ -27,13 +21,9 @@ spec:
containers:
- name: function # DO NOT change this
imagePullPolicy: IfNotPresent
runtime: "async"
inputs:
- name: cron
component: cron
outputs:
- name: sample
component: kafka-server
- name: kafka-server
type: bindings.kafka
operation: "create"
bindings:
cron:
Expand All @@ -56,3 +46,12 @@ spec:
value: "sample-topic"
- name: authRequired
value: "false"
triggers:
dapr:
- name: cron
type: bindings.cron
hooks:
post:
- dev.openfunction.samples.hooks.ExampleHook
pre:
- dev.openfunction.samples.hooks.ExampleHook
15 changes: 6 additions & 9 deletions samples/src/main/resources/function/cloudevent-function.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
apiVersion: core.openfunction.io/v1beta1
apiVersion: core.openfunction.io/v1beta2
kind: Function
metadata:
name: function-cloudevent
annotations:
plugins: |
pre:
- dev.openfunction.samples.plugins.ExamplePlugin
post:
- dev.openfunction.samples.plugins.ExamplePlugin
spec:
version: "v2.0.0"
image: "openfunctiondev/function-cloudevent-java:v1"
imageCredentials:
name: push-secret
port: 8080 # default to 8080
build:
builder: openfunctiondev/builder-java:v2-18
env:
Expand All @@ -28,4 +21,8 @@ spec:
containers:
- name: function # DO NOT change this
imagePullPolicy: IfNotPresent
runtime: "knative"
hooks:
post:
- dev.openfunction.samples.hooks.ExampleHook
pre:
- dev.openfunction.samples.hooks.ExampleHook
15 changes: 6 additions & 9 deletions samples/src/main/resources/function/http-function.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
apiVersion: core.openfunction.io/v1beta1
apiVersion: core.openfunction.io/v1beta2
kind: Function
metadata:
name: function-sample
annotations:
plugins: |
pre:
- dev.openfunction.samples.plugins.ExamplePlugin
post:
- dev.openfunction.samples.plugins.ExamplePlugin
spec:
version: "v2.0.0"
image: "openfunctiondev/sample-go-func-java:v1"
imageCredentials:
name: push-secret
port: 8080 # default to 8080
build:
builder: openfunctiondev/builder-java:v2-17
env:
Expand All @@ -28,4 +21,8 @@ spec:
containers:
- name: function # DO NOT change this
imagePullPolicy: IfNotPresent
runtime: "knative"
hooks:
post:
- dev.openfunction.samples.hooks.ExampleHook
pre:
- dev.openfunction.samples.hooks.ExampleHook
19 changes: 8 additions & 11 deletions samples/src/main/resources/function/http-with-output.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
apiVersion: core.openfunction.io/v1beta1
apiVersion: core.openfunction.io/v1beta2
kind: Function
metadata:
name: http-with-output
annotations:
plugins: |
pre:
- dev.openfunction.samples.plugins.ExamplePlugin
post:
- dev.openfunction.samples.plugins.ExamplePlugin
spec:
version: "v2.0.0"
image: "openfunctiondev/http-with-output-java:v1"
imageCredentials:
name: push-secret
port: 8080 # default to 8080
build:
builder: openfunctiondev/builder-java:v2-17
env:
Expand All @@ -28,10 +21,9 @@ spec:
containers:
- name: function # DO NOT change this
imagePullPolicy: IfNotPresent
runtime: "knative"
outputs:
- name: sample
component: kafka-server
- name: kafka-server
type: bindings.kafka
operation: "create"
bindings:
kafka-server:
Expand All @@ -48,3 +40,8 @@ spec:
value: "sample-topic"
- name: authRequired
value: "false"
hooks:
post:
- dev.openfunction.samples.hooks.ExampleHook
pre:
- dev.openfunction.samples.hooks.ExampleHook
37 changes: 18 additions & 19 deletions samples/src/main/resources/function/subcreibe-function.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
apiVersion: core.openfunction.io/v1beta1
apiVersion: core.openfunction.io/v1beta2
kind: Function
metadata:
annotations:
plugins: |
pre:
- dev.openfunction.samples.plugins.ExamplePlugin
post:
- dev.openfunction.samples.plugins.ExamplePlugin
name: autoscaling-subscriber
spec:
version: "v2.0.0"
Expand All @@ -25,9 +19,15 @@ spec:
sourceSubPath: "samples"
revision: "java"
serving:
runtime: "async"
scaleOptions:
keda:
triggers:
- type: kafka
metadata:
topic: "sample-topic"
bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092
consumerGroup: autoscaling-subscriber
lagThreshold: "20"
scaledObject:
pollingInterval: 15
minReplicaCount: 0
Expand All @@ -44,21 +44,10 @@ spec:
periodSeconds: 15
scaleUp:
stabilizationWindowSeconds: 0
triggers:
- type: kafka
metadata:
topic: "sample-topic"
bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092
consumerGroup: autoscaling-subscriber
lagThreshold: "20"
template:
containers:
- name: function # DO NOT change this
imagePullPolicy: IfNotPresent
inputs:
- name: producer
component: kafka-server
topic: "sample-topic"
pubsub:
kafka-server:
type: pubsub.kafka
Expand All @@ -72,3 +61,13 @@ spec:
value: "sample-topic"
- name: consumerID
value: "autoscaling-subscriber"
triggers:
dapr:
- name: kafka-server
type: bindings.cron
topic: "sample-topic"
hooks:
post:
- dev.openfunction.samples.hooks.ExampleHook
pre:
- dev.openfunction.samples.hooks.ExampleHook

0 comments on commit 4340417

Please sign in to comment.