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
Let's first write a simple workflows. Our workflow executes two _activities_ in sequence waiting for each result. Both workflows and activities are written in plain Go. Workflows can be long-running and have to be deterministic so that they can be interrupted and resumed. Activities are functions that can have side-effects and don't have to be deterministic.
61
+
Let's first write a simple workflow. Our workflow executes two _activities_ in sequence waiting for each result. Both workflows and activities are written in plain Go. Workflows can be long-running and have to be deterministic so that they can be interrupted and resumed. Activities are functions that can have side-effects and don't have to be deterministic.
62
62
63
63
Both workflows and activities support arbitrary inputs and outputs as long as those are serializable.
64
64
@@ -135,3 +135,71 @@ func main() {
135
135
To finish the example, we create the backend, start a worker in a separate go-routine. We then create a `Client` instance which we then use to create a new _workflow instance_. A workflow instance is just one running instance of a previously registered workflow.
136
136
137
137
With the exception of the in-memory backend, we do not have to start the workflow from the same process the worker runs in, we could create the client from another process and create/wait for/cancel/... workflow instances from there.
138
+
139
+
## Using the WorkflowOrchestrator
140
+
141
+
For simpler scenarios where you don't need the separation between client and worker, you can use the `WorkflowOrchestrator` which combines both:
142
+
143
+
```go
144
+
// Define the workflow with activities that will be auto-registered
fmt.Println("Workflow completed with result:", result)
202
+
}
203
+
```
204
+
205
+
The `WorkflowOrchestrator` provides automatic registration of workflows when passing workflow functions directly to `CreateWorkflowInstance`. For activities, the orchestrator automatically registers any activities used in the workflows via `ExecuteActivity` without explicit registration. Similarly, any sub-workflows created with `CreateSubWorkflowInstance` are registered automatically. This approach offers a unified API for workflow creation and execution in a single component, simplifying the development experience for simpler scenarios.
0 commit comments