- Notifications
You must be signed in to change notification settings - Fork50
Java SDK for Serverless Workflow
License
serverlessworkflow/sdk-java
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Provides the Java API for theServerless Workflow Specification
With the SDK you can:
- Read workflow JSON and YAML definitions
- Write workflow definitions in JSON and YAML formats.
- Test your workflow definitions using the reference implementation.
Latest Releases | Conformance to spec version |
---|---|
7.0.0.Final | v1.0.0 |
5.0.0.Final | v0.8 |
4.0.5.Final | v0.8 |
3.0.0.Final | v0.7 |
2.0.0.Final | v0.6 |
1.0.3.Final | v0.5 |
Note that 6.0.0.Final, which will be the one for specification version 0.9, is skipped intentionally in case someone want to work on it.
SDK Version | JDK Version |
---|---|
7.0.0 and after | 17 |
5.0.0 and after | 11 |
4.0.x and before | 8 |
To build project and run tests locally:
git clone https://github.com/serverlessworkflow/sdk-java.gitmvn clean install
The project usesGoogle's code styleguide.Your changes should be automatically formatted during the build.
Add the following dependencies to your pom.xmldependencies
section:
<dependency> <groupId>io.serverlessworkflow</groupId> <artifactId>serverlessworkflow-api</artifactId> <version>7.0.0.Final</version></dependency>
Add the following dependencies to your build.gradledependencies
section:
implementation("io.serverlessworkflow:serverlessworkflow-api:7.0.0.Final")
There are, roughly speaking, two kind of users of this SDK:
- Those ones interested on implementing their own runtime using Java.
- Those ones interested on using the provided runtime reference implementation.
For those ones interested on implementing their own runtime, this SDK provides an easy way to load an in memory representation of a given workflow definition.This in-memory representation consists of a hierarchy of POJOS directly generated from the Serverless Workflow specificationschema, which ensures the internal representation is aligned with the specification schema. The root of the hierarchy isio.serverlessworkflow.api.types.Workflow
class
You can read a Workflow definition from JSON/YAML source:
Let's say you have a simple YAML based workflow definition in a file namesimple.yaml
located in your working dir:
document:dsl:1.0.0-alpha1namespace:defaultname:implicit-sequencedo:setRed:set:colors:'${ .colors + [ "red" ] }'setGreen:set:colors:'${ .colors + [ "green" ] }'setBlue:set:colors:'${ .colors + [ "blue" ] }'
To parse it and get a Workflow instance you can do:
try (InputStreamin =newFileInputStream("simple.yaml")) {Workflowworkflow =WorkflowReader.readWorkflow (in,WorkflowFormat.YAML);// Once you have the Workflow instance you can use its API to inspect it}
By default, Workflows are not validated against the schema (performance being the priority). If you want to enable validation, you can do that by using:
try (InputStreamin =newFileInputStream("simple.yaml")) {Workflowworkflow =WorkflowReader.validation().readWorkflow (in,WorkflowFormat.YAML);// Once you have the Workflow instance you can use its API to inspect it}
For additional reading helper methods, including the one to read a workflow definition from classpath, checkWorkflowReader class.
Given a Workflow instance, you can store it using JSON or YAML format.For example, to store a workflow using json format in a file calledsimple.json
, you write
try (OutputStreamout =newFileOutputStream("simple.json")) {WorkflowWriter.writeWorkflow(out,workflow,WorkflowFormat.JSON);}
For additional writing helper methods, checkWorkflowWriter class.
The reference implementation provides a ready-to-use runtime that supports the Serverless Workflow Specification. It includes a workflow execution engine, validation utilities, and illustrative examples to help you quickly test and deploy your workflows. For details on usage, configuration, and supported features, seereadme.
About
Java SDK for Serverless Workflow
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.