You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-15Lines changed: 39 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,11 @@ Provides the Java API for the [Serverless Workflow Specification](https://github
8
8
With the SDK you can:
9
9
10
10
* Read workflow JSON and YAML definitions
11
-
* Write workflow in JSON and YAML format.
11
+
* Write workflow definition in JSON and YAML format.
12
+
* Test your workflow definitions using the reference implementation.
12
13
13
-
Serverless Workflow Java SDK is **not** a workflow runtime implementation but can be used by Java runtime implementations to parse workflow definitions.
14
14
15
-
###Status
15
+
## Status
16
16
17
17
| Latest Releases | Conformance to spec version |
18
18
| :---: | :---: |
@@ -25,17 +25,17 @@ Serverless Workflow Java SDK is **not** a workflow runtime implementation but ca
25
25
26
26
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.
27
27
28
-
###JDK Version
28
+
## JDK Version
29
29
30
30
| SDK Version | JDK Version |
31
31
| :---: | :---: |
32
32
| 5.0.0 and after | 11 |
33
33
| 4.0.x and before | 8 |
34
34
35
-
###Getting Started
35
+
## Getting Started
36
36
37
37
38
-
####Building SNAPSHOT locally
38
+
### Building SNAPSHOT locally
39
39
40
40
To build project and run tests locally:
41
41
@@ -47,7 +47,7 @@ mvn clean install
47
47
The project uses [Google's code styleguide](https://google.github.io/styleguide/javaguide.html).
48
48
Your changes should be automatically formatted during the build.
49
49
50
-
####Maven projects:
50
+
### Maven projects:
51
51
52
52
Add the following dependencies to your pom.xml `dependencies` section:
53
53
@@ -59,19 +59,28 @@ Add the following dependencies to your pom.xml `dependencies` section:
59
59
</dependency>
60
60
```
61
61
62
-
####Gradle projects:
62
+
### Gradle projects:
63
63
64
64
Add the following dependencies to your build.gradle `dependencies` section:
There are, roughly speaking, two kind of users of this SDK:
73
+
* Those ones interested on implementing their own runtime using Java.
74
+
* Those ones interested on using the provided runtime reference implementation.
73
75
74
-
You can create a Workflow instance from JSON/YAML source:
76
+
### Implementing your own runtime
77
+
78
+
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.
79
+
This memory representation consist of a hierarchy of POJOS directly generated from the Serverless Workflow specification [schema](api/src/main/resources/schema/workflow.yaml), which ensures the internal representation is aligned with the specification schema. The root of the hierarchy is `io.serverlessworkflow.api.types.Workflow` class
80
+
81
+
#### Reading workflow definition from JSON/YAML source
82
+
83
+
You can read a Workflow definition from JSON/YAML source:
75
84
76
85
Let's say you have a simple YAML based workflow definition in a file name `simple.yaml` located in your working dir:
77
86
@@ -93,7 +102,7 @@ do:
93
102
94
103
```
95
104
96
-
To parse it and create a Workflow instance you can do:
105
+
To parse it and get a Workflow instance you can do:
97
106
98
107
```java
99
108
@@ -102,15 +111,30 @@ try (InputStream in = new FileInputStream("simple.yaml")) {
102
111
// Once you have the Workflow instance you can use its API to inspect it
103
112
}
104
113
```
114
+
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:
105
115
106
-
#### Writing a workflow
116
+
```java
117
+
try (InputStream in =newFileInputStream("simple.yaml")) {
// Once you have the Workflow instance you can use its API to inspect it
120
+
}
121
+
```
122
+
123
+
For additional reading helper methods, including the one to read a workflow definition from classpath, check [WorkflowReader](api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java) class.
124
+
125
+
#### Writing workflow definition to a a JSON/YAML target
107
126
108
-
Given a workflow definition, you can store it using JSON or YAML format.
127
+
Given a Workflow instance, you can store it using JSON or YAML format.
109
128
For example, to store a workflow using json format in a file called `simple.json`, you write
110
129
111
130
```java
112
131
try (OutputStream out =newFileOutputStream("simple.json")) {
0 commit comments