Skip to content

Commit cbd1623

Browse files
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]>
1 parent 8c0453e commit cbd1623

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

impl/README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Reference implementation requires [Java 17](https://openjdk.org/projects/jdk/17/
4848

4949
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.
5050

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)
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 need (for example, when gRPC call will be implemented, if we were adding the gRPC stack to the core dependencies, you won't be able to get rid of it even if none of your workflows use it)
5252

5353
#### Maven
5454

@@ -91,18 +91,18 @@ implementation("io.serverlessworkflow:serverlessworkflow-impl-http:7.0.0-SNAPSHO
9191

9292
## How to use
9393

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

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

9898
### Quick version
9999

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.
100+
For a quick introduction, we will use a simple workflow [definition](../examples/simpleGet/src/main/resources/get.yaml) that performs a get call.
101101
We are going to show two ways of invoking the workflow:
102102
- blocking the thread till the get request goes through
103103
- returning control to the caller, so the main thread continues while the get is executed
104104

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

107107
``` java
108108
try (WorkflowApplication appl = WorkflowApplication.builder().build()) {
@@ -116,7 +116,7 @@ try (WorkflowApplication appl = WorkflowApplication.builder().build()) {
116116
```
117117
You can find the complete java code [here](../examples/simpleGet/src/main/java/BlockingExample.java)
118118

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

121121
``` java
122122
try (WorkflowApplication appl = WorkflowApplication.builder().build()) {
@@ -126,9 +126,11 @@ In order to execute the workflow, without blocking the calling thread till the h
126126
.thenAccept(node -> logger.info("Workflow output is {}", node));
127127
}
128128
```
129-
When the http request is done, both examples will print a similar output
129+
When the HTTP request is done, both examples will print a similar output
130130

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

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

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

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.
143+
Here is a summary of what we are trying to do: We will start the `listen.yaml` workflow, which will be completed when it receives an event with the proper temperature. It won't block the main thread while waiting for it. Then, we will send an event with a lower temperature that will be ignored. Finally, we will send an event with a higher temperature to complete the waiting workflow.
142144
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)
145+
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)
144146
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.
147+
Since `WorkflowApplication` implements `Autocloseable`, we better use a try...finally block, ensuring any resource that the workflow might have used is freed when done.
146148
147149
`try (WorkflowApplication appl = WorkflowApplication.builder().build())`
148150
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.
151+
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.
150152
151153
```java
152154
WorkflowDefinition listenDefinition =
@@ -155,9 +157,9 @@ Once we have the application object, we use it to parse our definition examples.
155157
appl.workflowDefinition(WorkflowReader.readWorkflowFromClasspath("emit.yaml"));
156158
```
157159
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.
160+
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.
159161
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.
162+
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.
161163
162164
```java
163165
WorkflowInstance waitingInstance = listenDefinition.instance(Map.of());
@@ -168,13 +170,13 @@ To execute a workflow, we first create a [WorkflowInstance](core/src/main/java/i
168170
169171
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.
170172
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.
173+
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 before executing the following line, we call `join` after `start`, telling the `CompletableFuture` to wait for workflow completion.
172174
173175
```java
174176
emitDefinition.instance(Map.of("temperature", 35)).start().join();
175177
```
176178
177-
Now its time to complete the waiting instance and send an event with the expected temperature. We do so by reusing `emitDefinition`.
179+
It's time to complete the waiting instance and send an event with the expected temperature. We do so by reusing `emitDefinition`.
178180

179181
```java
180182
emitDefinition.instance(Map.of("temperature", 39)).start().join();

0 commit comments

Comments
 (0)