The Fn Java FDK helps you build, test and run Java functions on the Fn platform.
The FDK is comprised of:
- a Java library (known as the
api
); - a runtime Docker image (known as the
runtime
); - a JUnit rule;
- a build-time Docker image for repeatable builds.
No. You can still write Java functions on Fn without using the FDK. However using the FDK will make several things easier for you:
- A curated base image for Java 8 and Java 9 means that you don't have to build and maintain your own image. These images contain optimizations for quick JVM startup times.
- Accessing configuration from Fn is easy through FDK APIs.
- Input and output type coercion reduces the amount of serialization and formatting boilerplate that you have to write.
- A JUnit rule provides a realistic test harness for you to test your function in isolation.
Fn Flow is a Java API and corresponding service that helps you create complex, long-running, fault-tolerant functions using a promises-style asynchronous API. Check out the Fn Flow docs for more information.
The FDK is automatically added to your project if you built your function using fn init --runtime=java
. The api
and testing
JARs are published on our bintray and the runtime
is published in our Docker hub repository.
- Find the latest release from the releases page. For example
1.0.32
. - The FDK JAR is published on Bintray. Add the repository to your
pom.xml
repositories
section:
<repository>
<id>fn-release-repo</id>
<url>https://dl.bintray.com/fnproject/fnproject</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
- Add the dependency to your
dependency
section. Make sure that theversion
tag matches the latest release that you looked up above.
<dependency>
<groupId>com.fnproject.fn</groupId>
<artifactId>api</artifactId>
<version>1.0.32</version>
</dependency>
- If you want the JUnit support also add:
<dependency>
<groupId>com.fnproject.fn</groupId>
<artifactId>testing</artifactId>
<version>1.0.32</version>
<scope>test</scope>
</dependency>
Have a look on our releases page.
- Find the latest version from our releases page.
- Update the Java
api
version: change your dependency management system to reference the latest artifact. For example to upgrade a maven build to use1.0.32
:
<dependency>
<groupId>com.fnproject.fn</groupId>
<artifactId>api</artifactId>
<version>1.0.32</version>
</dependency>
<dependency>
<groupId>com.fnproject.fn</groupId>
<artifactId>testing</artifactId>
<version>1.0.32</version>
<scope>test</scope>
</dependency>
-
Update your runtime image:
- To latest:
docker pull fnproject/fn-java-fdk
- To a specific version:
docker pull fnproject/fn-java-fdk:1.0.32 docker tag fnproject/fn-java-fdk:1.0.32 fnproject/fn-java-fdk:latest
You should keep versions of com.fnproject.fn.api
, com.fnproject.fn.testing
and your runtime Docker image in sync with each other.
- Update your build image:
docker pull fnproject/fn-java-fdk-build
Please create an issue on our GitHub repo.
We hang out on the Fn project slack in #fn-flow, #fn-java-fdk.
Please see our Fn Flow User Guide for information on how to get started with Fn Flow in Java.
Use Fn Flow when:
- You want to compose the work of several other Fn functions in a reliable and scalable way.
- You find yourself wanting to write code that blocks on the result of another Fn call.
- You feel tempted to reach for another workflow system or library.
No. java.util.concurrent.Flow
is a stream-processing API for running code in a single JVM. Fn Flow is a distributed promise API for writing long-running, fault-tolerant asynchronous functions.
No. Fn Flow was released in 2017 and is not related to any other Java library.
Fn Flow was 'inspired by' the CompletionStage
API and shares a number of similar methods. However, as the semantics of Fn Flow are subtly different, and because we require our operations to implement Serializable
we have implemented a new API.
Fn Flow is open source just like the rest of the Fn project. You can get the code and run a server easily.