Deploy Event Functions with .zip or JAR file archives

Package Specification

JAR Package

If the function does not reference any third-party software, you can directly compile the function project into a JAR package.

Note

The maximum size of a JAR to be uploaded using console is 40MB, for larger files store JAR in OBS

Example JAR Package

Example JAR package structure
example.jar
├─ com
|  └─ sample                              # FunctionGraph handler
|  |  └─ SampleFunctionHandler.class
|  └─ opentelekomcloud                     # OpenTelekomCloud dependencies
|     └─ services
|        └─ runtime
|           └─ Context.class
|           └─ RuntimeLogger.class
|           └─ Runtime.class
|           └─ ...
|        └─ functiongraph
|           └─ runtime
|              └─ core
|              |  └─ ...
|              └─ entity
|                 └─ ...

Jar with dependencies

Using maven-assembly-plugin a jar with all dependencies will be created. This file *-jar-with-dependencies located in the target folder can be used as deployment file.

ZIP Package

If the function references a third-party software, compile the function project into a Jar package, and then package all the dependent third-party software and the function JAR package into a ZIP package.

Note

The maximum size of a ZIP to be uploaded using console is 40MB, for larger files store ZIP in OBS.

Example ZIP Package

Example ZIP package structure
example.zip
├─ myfunctionhandler.jar                                        # business function JAR package
├─ opentelekomcloud-functiongraph-java-core-1.0.0.jar   # OTC dependency JAR package
├─ opentelekomcloud-functiongraph-java-events-1.0.0.jar # OTC dependency JAR package
├─ gson-2.11.0.jar                                              # third-party dependency JAR package
├─ handler.txt                                                  # optional file with name of handler
└─ ...

OBS

Package the project into a ZIP package and upload it to the OBS storage bucket.

Building a deployment package

Deployment packages can be built using maven.

Following snippets show how to build JAR Package with dependencies using maven.

See full code in doc-sample-deploy

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.github.opentelekomcloud</groupId>
    <artifactId>opentelekomcloud-functiongraph-java-samples-doc-pom</artifactId>
    <version>1.0.0</version>
  </parent>

  <groupId>io.github.opentelekomcloud</groupId>
  <artifactId>opentelekomcloud-functiongraph-java-samples-doc-deploy</artifactId>
  <name>opentelekomcloud-functiongraph-java-samples-doc-deploy</name>
  <packaging>jar</packaging>

  <url>https://docs.otc.t-systems.com/opentelekomcloud-functiongraph-java</url>
  <description>Open Telekom Cloud FunctionGraph Java SDK samples documentation for deploying</description>

  <scm>
    <connection>scm:git:git://github.com/opentelekomcloud/opentelekomcloud-functiongraph-java.git</connection>
    <developerConnection>scm:git:ssh://github.com:opentelekomcloud/opentelekomcloud-functiongraph-java.git</developerConnection>
    <url>http://github.com/opentelekomcloud/opentelekomcloud-functiongraph-java/tree/main</url>
  </scm>

  <dependencies>
    <dependency>
      <groupId>io.github.opentelekomcloud</groupId>
      <artifactId>opentelekomcloud-functiongraph-java-core</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>

  <build>

    <plugins>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifestEntries>
              <FunctionGraph-Handler-Name>com.opentelekomcloud.samples.SampleFG.handleRequest</FunctionGraph-Handler-Name>
            </manifestEntries>
          </archive>
          <finalName>${project.name}</finalName>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

</project>

Generated JAR file can be found in folder ${PROJECT_ROOT}/target/doc-sample-deploy-jar-with-dependencies.jar

Deployment with the FunctionGraph console

See: Creating an Event Function