Skip to content

Commit b98e112

Browse files
fjtiradogmunozfe
andcommitted
Update impl/README.md
Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> Update impl/README.md Co-authored-by: Ricardo Zanini <[email protected]> [Fix #520] More comments Update README.md Co-authored-by: Gonzalo Muñoz <[email protected]> Update impl/README.md Co-authored-by: Gonzalo Muñoz <[email protected]> Update impl/README.md Co-authored-by: Gonzalo Muñoz <[email protected]> Update README.md Co-authored-by: Gonzalo Muñoz <[email protected]> Update README.md Co-authored-by: Gonzalo Muñoz <[email protected]> Update README.md Co-authored-by: Gonzalo Muñoz <[email protected]> Update impl/README.md Co-authored-by: Gonzalo Muñoz <[email protected]> Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
1 parent 8c0453e commit b98e112

File tree

2 files changed

+45
-38
lines changed

2 files changed

+45
-38
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Provides the Java API for the [Serverless Workflow Specification](https://github
88
With the SDK you can:
99

1010
* Read workflow JSON and YAML definitions
11-
* Write workflow definition in JSON and YAML format.
11+
* Write workflow definitions in JSON and YAML formats.
1212
* Test your workflow definitions using the reference implementation.
1313

1414

@@ -29,6 +29,7 @@ Note that 6.0.0.Final, which will be the one for specification version 0.9, is s
2929

3030
| SDK Version | JDK Version |
3131
| :---: | :---: |
32+
| 7.0.0 and after | 17 |
3233
| 5.0.0 and after | 11 |
3334
| 4.0.x and before | 8 |
3435

@@ -76,9 +77,9 @@ There are, roughly speaking, two kind of users of this SDK:
7677
### Implementing your own runtime
7778

7879
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+
This in-memory representation consists 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
8081

81-
#### Reading workflow definition from JSON/YAML source
82+
### Reading workflow definition from JSON/YAML source
8283

8384
You can read a Workflow definition from JSON/YAML source:
8485

@@ -122,7 +123,7 @@ try (InputStream in = new FileInputStream("simple.yaml")) {
122123

123124
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.
124125

125-
#### Writing workflow definition to a a JSON/YAML target
126+
### Writing workflow definition to a JSON/YAML target
126127

127128
Given a Workflow instance, you can store it using JSON or YAML format.
128129
For example, to store a workflow using json format in a file called `simple.json`, you write
@@ -136,5 +137,6 @@ try (OutputStream out = new FileOutputStream("simple.json")) {
136137
For additional writing helper methods, check [WorkflowWriter](api/src/main/java/io/serverlessworkflow/api/WorkflowWriter.java) class.
137138

138139
### Reference implementation
139-
See Reference implementation [readme](impl/README.md).
140+
141+
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, see [readme](impl/README.md).
140142

impl/README.md

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Welcome to Java SDK runtime reference implementation, a lightweight implementati
77

88
Although initially conceived mainly for testing purposes, it was designed to be easily expanded, so it can eventually become production ready.
99

10-
## Status.
10+
## Status
1111

1212
This reference implementation is currently capable of running workflows consisting of:
1313

@@ -38,17 +38,18 @@ This reference implementation is currently capable of running workflows consisti
3838

3939
## Setup
4040

41-
Serverless workflow reference implementation only requires setting up Java and Maven/Gradle.
41+
Before getting started, ensure you have Java 17+ and Maven or Gradle installed.
4242

43-
### JDK Version
44-
45-
Reference implementation requires [Java 17](https://openjdk.org/projects/jdk/17/) or newer versions.
43+
Install [Java 17](https://openjdk.org/projects/jdk/17/)
44+
Install [Maven](https://maven.apache.org/install.html) (if using Maven)
45+
Install [Gradle](https://gradle.org/install) (if using Gradle)
4646

4747
### Dependencies
4848

49-
One of the goals of the reference implementation is to maintain the number of dependencies as lower as possible. With that spirit, a modular approach has been followed, letting the users decide, depending on their workflows nature, which dependencies should be include.
50-
51-
In practical terms, this means a separation between the core part and additional dependencies that should be explicitly included if your workflow is interacting with an external service that communicated using a particular technology supported by the specification (at this moment, just HTTP). The intention of this is to avoid adding dependencies that you do not really need (for example, when gRPC call will be implemented, if we were adding the gRPC stack to the core dependencies, you wont be able to get rid of it even if none of your workflows use it)
49+
This implementation follows a modular approach, keeping dependencies minimal:
50+
- The core library is always required.
51+
- Additional dependencies must be explicitly included if your workflow interacts with external services (e.g., HTTP).
52+
This ensures you only include what you need, preventing unnecessary dependencies.
5253

5354
#### Maven
5455

@@ -58,7 +59,7 @@ You always need to add this dependency to your pom.xml `dependencies` section:
5859
<dependency>
5960
<groupId>io.serverlessworkflow</groupId>
6061
<artifactId>serverlessworkflow-impl-core</artifactId>
61-
<version>7.0.0-SNAPSHOT</version>
62+
<version>7.0.0</version>
6263
</dependency>
6364
```
6465

@@ -68,41 +69,38 @@ And only if your workflow is using HTTP calls, you must add:
6869
<dependency>
6970
<groupId>io.serverlessworkflow</groupId>
7071
<artifactId>serverlessworkflow-impl-http</artifactId>
71-
<version>7.0.0-SNAPSHOT</version>
72+
<version>7.0.0</version>
7273
</dependency>
7374
```
7475

75-
76-
77-
### Gradle projects:
76+
#### Gradle projects:
7877

7978
You always need to add this dependency to your build.gradle `dependencies` section:
8079

8180
```text
82-
implementation("io.serverlessworkflow:serverlessworkflow-impl-core:7.0.0-SNAPSHOT")
81+
implementation("io.serverlessworkflow:serverlessworkflow-impl-core:7.0.0")
8382
```
8483

8584
And only if your workflow is using HTTP calls, you must add:
8685

8786
```text
88-
implementation("io.serverlessworkflow:serverlessworkflow-impl-http:7.0.0-SNAPSHOT")
87+
implementation("io.serverlessworkflow:serverlessworkflow-impl-http:7.0.0")
8988
```
9089

91-
9290
## How to use
9391

94-
Quick version is intended for impatient users that want to try something as soon as possible.
92+
The quick version is intended for impatient users who want to try something as soon as possible.
9593

96-
Detailed version is more suitable for those users interested on a more thoughtful discussion of the API.
94+
The detailed version is more suitable for those users interested in a more thoughtful discussion of the API.
9795

9896
### Quick version
9997

100-
For a quick introduction, we are going to use a simple workflow [definition](../examples/simpleGet/src/main/resources/get.yaml) that performs a get call.
98+
For a quick introduction, we will use a simple workflow [definition](../examples/simpleGet/src/main/resources/get.yaml) that performs a get call.
10199
We are going to show two ways of invoking the workflow:
102100
- blocking the thread till the get request goes through
103101
- returning control to the caller, so the main thread continues while the get is executed
104102

105-
In order to execute the workflow, blocking the thread till the http request is completed, you should write
103+
In order to execute the workflow, blocking the thread till the HTTP request is completed, you should write
106104

107105
``` java
108106
try (WorkflowApplication appl = WorkflowApplication.builder().build()) {
@@ -116,7 +114,7 @@ try (WorkflowApplication appl = WorkflowApplication.builder().build()) {
116114
```
117115
You can find the complete java code [here](../examples/simpleGet/src/main/java/BlockingExample.java)
118116

119-
In order to execute the workflow, without blocking the calling thread till the http request is completed, you should write
117+
In order to execute the workflow without blocking the calling thread till the HTTP request is completed, you should write
120118

121119
``` java
122120
try (WorkflowApplication appl = WorkflowApplication.builder().build()) {
@@ -126,9 +124,12 @@ In order to execute the workflow, without blocking the calling thread till the h
126124
.thenAccept(node -> logger.info("Workflow output is {}", node));
127125
}
128126
```
129-
When the http request is done, both examples will print a similar output
127+
When the HTTP request is done, both examples will print a similar output
128+
130129

131-
`Workflow output is {"id":10,"category":{"id":10,"name":"string"},"name":"doggie","photoUrls":["string"],"tags":[{"id":10,"name":"string"}],"status":"string"}`
130+
```shell
131+
Workflow output is {"id":10,"category":{"id":10,"name":"string"},"name":"doggie","photoUrls":["string"],"tags":[{"id":10,"name":"string"}],"status":"string"}
132+
```
132133

133134
You can find the complete java code [here](../examples/simpleGet/src/main/java/NotBlockingExample.java)
134135

@@ -138,15 +139,19 @@ To discuss runtime API we are going to use a couple of workflow:
138139
- [listen.yaml](../examples/events/src/main/listen.yaml), which waits for an event reporting a temperature greater than 38
139140
- [emit.yaml](../examples/events/src/main/emit.yaml), which emits events with a certain temperature, specified as workflow parameter.
140141

141-
A brief summary of what we are trying to do. We will start listen.yaml, which will complete when it receives an event with the proper temperature, but it wont block the main thread while waiting for it. Then, we will send an event with a lower temperature, that will be ignored. And finally, we will send an event with a greater temperature, that will complete the waiting workflow.
142+
Here is a summary of what we are trying to do:
143+
144+
- The listen.yaml workflow waits for an event (not-blocking).
145+
- We send an event with a low temperature (ignored).
146+
- We send an event with a high temperature (completes the workflow).
142147

143-
The first step is to create a [WorkflowApplication](core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java) instance. An application is an abstraction that allow customization of different aspect of the workflow execution (for example change the default `ExecutorService` for thread spawning)
148+
The first step is to create a [WorkflowApplication](core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java) instance. An application is an abstraction that allows customization of different aspects of the workflow execution (for example, change the default `ExecutorService` for thread spawning)
144149

145-
Since `WorkflowApplication` implements `Autocloseable`, we better use a try...finally block, ensuring any resource that might have been used by the workflow is freed when done.
150+
Since `WorkflowApplication` implements `Autocloseable`, we better use a **try-with-resources** block, ensuring any resource that the workflow might have used is freed when done.
146151

147152
`try (WorkflowApplication appl = WorkflowApplication.builder().build())`
148153

149-
Once we have the application object, we use it to parse our definition examples. To load each workflow definition, we use `readFromClasspath` helper method defined in [WorkflowReader](api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java) class.
154+
Once we have the application object, we use it to parse our definition examples. To load each workflow definition, we use the `readFromClasspath` helper method defined in [WorkflowReader](api/src/main/java/io/serverlessworkflow/api/WorkflowReader.java) class.
150155

151156
```java
152157
WorkflowDefinition listenDefinition =
@@ -155,9 +160,9 @@ Once we have the application object, we use it to parse our definition examples.
155160
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("emit.yaml"));
156161
```
157162

158-
A [WorkflowDefinition](core/src/main/java/io/serverlessworkflow/impl/WorkflowDefinition.java) object is immutable and therefore thread safe. It is used to execute as many workflow instances as desired.
163+
A [WorkflowDefinition](core/src/main/java/io/serverlessworkflow/impl/WorkflowDefinition.java) object is immutable and, therefore, thread-safe. It is used to execute as many workflow instances as desired.
159164

160-
To execute a workflow, we first create a [WorkflowInstance](core/src/main/java/io/serverlessworkflow/impl/WorkflowInstance.java) object (the initial status is PENDING) and then invoke `start` method on it (the status is changed to RUNNING). `start` method returns a [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), which we use to indicate that a log message should be printed when the workflow is completed.
165+
To execute a workflow, we first create a [WorkflowInstance](core/src/main/java/io/serverlessworkflow/impl/WorkflowInstance.java) object (its initial status is PENDING) and then invoke the `start` method on it (its status is changed to RUNNING). The `start` method returns a [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), which we use to indicate that a log message should be printed when the workflow is completed.
161166

162167
```java
163168
WorkflowInstance waitingInstance = listenDefinition.instance(Map.of());
@@ -166,15 +171,15 @@ To execute a workflow, we first create a [WorkflowInstance](core/src/main/java/i
166171
.thenAccept(node -> logger.info("Waiting instance completed with result {}", node));
167172
```
168173

169-
The next line will be executed as soon as the workflow execution starts waiting for events to arrive, moment at which control is returned to the calling thread. Therefore, we can execute another workflow instance while the first one is waiting.
174+
As soon as the workflow execution reach the point where it waits for events to arrive, control is returned to the calling thread. Since the execution is not blocking, we can execute another workflow instance while the first one is waiting.
170175

171-
We are going to send an event with a temperature that does not satisfy the criteria, so the listen instance will continue waiting. To pass parameters to the workflow instance that sends the event, we use a regular Java `Map`. Notice that, since we want to wait till the event is published before executing the next line, we call `join` after `start`, telling the `CompletableFuture` to wait for workflow completion.
176+
We will send an event with a temperature that does not satisfy the criteria, so the listen instance will continue waiting. We use a regular Java `Map` to pass parameters to the workflow instance that sends the event. Note that since we want to wait till the event is published, we call `join` after `start`, telling the `CompletableFuture` to wait for workflow completion.
172177

173178
```java
174179
emitDefinition.instance(Map.of("temperature", 35)).start().join();
175180
```
176181

177-
Now its time to complete the waiting instance and send an event with the expected temperature. We do so by reusing `emitDefinition`.
182+
It's time to complete the waiting instance and send an event with the expected temperature. We do so by reusing `emitDefinition`.
178183

179184
```java
180185
emitDefinition.instance(Map.of("temperature", 39)).start().join();
@@ -185,5 +190,5 @@ After that, listen instance will be completed and we will see this log message
185190
```java
186191
[pool-1-thread-1] INFO events.EventExample - Waiting instance completed with result [{"temperature":39}]
187192
```
188-
The source code of the example is here (../examples/events/src/main/java/EventExample.java)
193+
The source code of the example is [here](../examples/events/src/main/java/EventExample.java)
189194

0 commit comments

Comments
 (0)