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
@@ -197,10 +197,12 @@ public class DemoWorkflowActivity implements WorkflowActivity {
197
197
198
198
<!--go-->
199
199
200
+
### Define workflow activities
201
+
200
202
Define each workflow activity you'd like your workflow to perform. The Activity input can be unmarshalled from the context with `ctx.GetInput`. Activities should be defined as taking a `ctx workflow.ActivityContext` parameter and returning an interface and error.
Define your workflow function with the parameter `ctx *workflow.WorkflowContext` and return any and error. Invoke your defined activities from within your workflow.
Before your application can execute workflows, you must register both the workflow orchestrator and its activities with a workflow registry. This ensures Dapr knows which functions to call when executing your workflow.
- Use `workflow.NewRegistry()` to create a workflow registry
291
+
- Use `r.AddWorkflow()` to register workflow functions
292
+
- Use `r.AddActivity()` to register activity functions
293
+
- Use `client.NewWorkflowClient()` to create a workflow client
294
+
- Call `wclient.StartWorker()` to begin processing workflows
295
+
- Use `wclient.ScheduleWorkflow` to schedule a named instance of a workflow
296
+
214
297
[See the Go SDK workflow activity example in context.](https://github.com/dapr/go-sdk/tree/main/examples/workflow/README.md)
215
298
216
299
{{% /tab %}}
@@ -383,16 +466,16 @@ public class DemoWorkflowWorker {
383
466
Define your workflow function with the parameter `ctx *workflow.WorkflowContext` and return any and error. Invoke your defined activities from within your workflow.
@@ -864,7 +947,7 @@ public class DemoWorkflow extends Workflow {
864
947
[As in the following example](https://github.com/dapr/go-sdk/tree/main/examples/workflow/README.md), a hello-world application using the Go SDK and Dapr Workflow would include:
865
948
866
949
- A Go package called `client` to receive the Go SDK client capabilities.
867
-
- The `TestWorkflow` method
950
+
- The `BusinessWorkflow` method
868
951
- Creating the workflow with input and output.
869
952
- API calls. In the example below, these calls start and call the workflow activities.
870
953
@@ -889,15 +972,15 @@ var failActivityTries = 0
889
972
func main() {
890
973
r :=workflow.NewRegistry()
891
974
892
-
if err :=r.AddWorkflow(TestWorkflow); err != nil {
975
+
if err :=r.AddWorkflow(BusinessWorkflow); err != nil {
893
976
log.Fatal(err)
894
977
}
895
-
fmt.Println("TestWorkflow registered")
978
+
fmt.Println("BusinessWorkflow registered")
896
979
897
-
if err :=r.AddActivity(TestActivity); err != nil {
980
+
if err :=r.AddActivity(BusinessActivity); err != nil {
898
981
log.Fatal(err)
899
982
}
900
-
fmt.Println("TestActivity registered")
983
+
fmt.Println("BusinessActivity registered")
901
984
902
985
if err :=r.AddActivity(FailActivity); err != nil {
903
986
log.Fatal(err)
@@ -921,7 +1004,7 @@ func main() {
921
1004
// "start". This is useful for increasing the throughput of creating
The diagram below shows an example scenario of a complex workflow that orchestrates across multiple applications that are written in different languages. Each applications' main steps and activities are:
25
+
26
+
• **App1: Main Workflow Service** - Top-level orchestrator that coordinates the entire ML pipeline
27
+
- Starts the process
28
+
- Calls data processing activities on App2
29
+
- Calls ML training child workflow on App3
30
+
- Calls model deployment on App4
31
+
- Ends the complete workflow
32
+
-**Language: Java**
33
+
34
+
• **App2: Data Processing Pipeline** - **GPU activities** only
35
+
- Data Ingesting Activity (GPU-accelerated)
36
+
- Feature Engineering Activity (GPU-accelerated)
37
+
- Returns completion signal to Main Workflow
38
+
-**Language: Go**
39
+
40
+
• **App3: ML Training Child Workflow** - Contains a child workflow and activities
41
+
- Child workflow orchestrates:
42
+
- Data Processing Activity
43
+
- Model Training Activity (GPU-intensive)
44
+
- Model Validation Activity
45
+
- Triggered by App2's activities completing
46
+
- Returns completion signal to Main Workflow
47
+
-**Language: Java**
48
+
49
+
• **App4: Model Serving Service** - **Beefy GPU app** with activities only
Like all building blocks in Dapr, workflow execution routing is based on the [App ID of the hosting Dapr application]({{% ref "security-concept.md#application-identity" %}}).
58
+
Workflow execution routing is based on the [App ID of the hosting Dapr application]({{% ref "security-concept.md#application-identity" %}}).
26
59
By default, the full workflow execution is hosted on the app ID that started the workflow. This workflow can be executed across any replicas of that app ID, not just the single replica which scheduled the workflow.
27
60
28
61
29
-
It is possible to execute activities or child workflows on different app IDs by specifying the target app ID parameter, inside the workflow execution code.
30
-
Upon execution, the target app ID will execute the activity or child workflow, and return the result to the parent workflow of the originating app ID.
62
+
It is possible to execute activities and child workflows on different app IDs by specifying the target app ID parameter, inside the workflow execution code.
63
+
Upon execution, the target app ID executes the activity or child workflow, and returns the result to the parent workflow of the originating app ID.
31
64
32
65
The entire Workflow execution may be distributed across multiple app IDs with no limit, with each activity or child workflow specifying the target app ID.
33
66
The final history of the workflow will be saved by the app ID that hosts the very parent (or can consider it the root) workflow.
-**SDKs supporting multi-application workflows** - Multi-application workflows are used via the SDKs. Currently Java (activities calling) and Go (both activities and child workflows calling) SDKs are supported. The SDKs (Python, .NET, JavaScript) are planned for future releases.
76
+
**SDKs supporting multi-application workflows** - Multi-application workflows are used via the SDKs.
77
+
Currently the following are supported:
78
+
-**Java** (**only** activity calls)
79
+
-**Go** (**both** activities and child workflows calls)
80
+
- The Python, .NET, JavaScript SDKs support are planned for future releases
44
81
{{% /alert %}}
45
82
46
83
## Error handling
@@ -63,7 +100,7 @@ The following example shows how to execute the activity `ActivityA` on the targe
0 commit comments