Skip to content

Commit 7c63bb9

Browse files
authored
add workflow to client doc (#657)
Signed-off-by: Hannah Hunter <[email protected]>
1 parent 31346f0 commit 7c63bb9

File tree

1 file changed

+43
-0
lines changed
  • daprdocs/content/en/go-sdk-docs/go-client

1 file changed

+43
-0
lines changed

daprdocs/content/en/go-sdk-docs/go-client/_index.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,49 @@ if res.Error != nil {
245245

246246
For a full guide on pub/sub, visit [How-To: Publish & subscribe]({{< ref howto-publish-subscribe.md >}}).
247247

248+
### Workflow
249+
250+
You can create [workflows]({{< ref workflow-overview.md >}}) using the Go SDK. For example, start with a simple workflow activity:
251+
252+
```go
253+
func TestActivity(ctx workflow.ActivityContext) (any, error) {
254+
var input int
255+
if err := ctx.GetInput(&input); err != nil {
256+
return "", err
257+
}
258+
259+
// Do something here
260+
return "result", nil
261+
}
262+
```
263+
264+
Write a simple workflow function:
265+
266+
```go
267+
func TestWorkflow(ctx *workflow.WorkflowContext) (any, error) {
268+
var input int
269+
if err := ctx.GetInput(&input); err != nil {
270+
return nil, err
271+
}
272+
var output string
273+
if err := ctx.CallActivity(TestActivity, workflow.ActivityInput(input)).Await(&output); err != nil {
274+
return nil, err
275+
}
276+
if err := ctx.WaitForExternalEvent("testEvent", time.Second*60).Await(&output); err != nil {
277+
return nil, err
278+
}
279+
280+
if err := ctx.CreateTimer(time.Second).Await(nil); err != nil {
281+
return nil, nil
282+
}
283+
return output, nil
284+
}
285+
```
286+
287+
Then compose your application that will use the workflow you've created. [Refer to the How-To: Author workflows guide]({{< ref howto-author-workflow.md >}}) for a full walk-through.
288+
289+
Try out the [Go SDK workflow example.](https://github.com/dapr/go-sdk/blob/main/examples/workflow)
290+
248291
### Output Bindings
249292

250293

0 commit comments

Comments
 (0)