GH-731 Add support for SDK CloudEvent type

The type itself comes form cloud event sdk. And while s-c-function provides native support for cloud events, this is necessary for cases when user uses CloudEvent type in the signature of a function

Resolves #731
This commit is contained in:
Oleg Zhurakousky
2021-08-31 17:15:51 +02:00
parent f2a46fd980
commit 84840f79ba
9 changed files with 91 additions and 33 deletions

View File

@@ -25,8 +25,30 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-api</artifactId>
<version>2.2.0</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,16 @@
package function.example;
import java.util.Map;
import java.util.function.Function;
import io.cloudevents.CloudEvent;
public class EchoCloudEventFunction implements Function<CloudEvent, CloudEvent> {
@Override
public CloudEvent apply(CloudEvent value) {
System.out.println("Received " + value);
return value;
}
}

View File

@@ -1,13 +0,0 @@
package function.example;
import java.util.function.Function;
public class UpperCaseFunction implements Function<String, String> {
@Override
public String apply(String value) {
System.out.println("Uppercasing " + value);
return value.toUpperCase();
}
}