Skip to content

Commit

Permalink
Merge pull request dapr#4052 from mikeee/wf-docs
Browse files Browse the repository at this point in the history
add go limitations
  • Loading branch information
hhunter-ms authored Mar 4, 2024
2 parents 0122d1f + a0d3b23 commit 19d807b
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const randomString = getRandomString();

```go
// DON'T DO THIS!

const currentTime = time.Now()
```

{{% /codetab %}}
Expand Down Expand Up @@ -254,13 +254,12 @@ const randomString = yield context.callActivity(getRandomString);

{{% /codetab %}}


{{% codetab %}}

```go
// Do this!!

const currentTime = ctx.CurrentUTCDateTime()
```

{{% /codetab %}}

{{< /tabs >}}
Expand Down Expand Up @@ -319,10 +318,12 @@ fetch('https://postman-echo.com/get')

```go
// DON'T DO THIS!
resp, err := http.Get("http://example.com/api/data")
```

{{% /codetab %}}


{{< /tabs >}}

Do this:
Expand Down Expand Up @@ -364,6 +365,8 @@ const data = yield ctx.callActivity(makeHttpCall, "https://example.com/api/data"

```go
// Do this!!
err := ctx.CallActivity(MakeHttpCallActivity, workflow.ActivityInput("https://example.com/api/data")).Await(&output)

```

{{% /codetab %}}
Expand Down Expand Up @@ -412,9 +415,16 @@ Don't declare JavaScript workflow as `async`. The Node.js runtime doesn't guaran

```go
// DON'T DO THIS!
go func() {
err := ctx.CallActivity(DoSomething).Await(nil)
}()
err := ctx.CreateTimer(time.Second).Await(nil)
```

{{% /codetab %}}



{{< /tabs >}}

Do this:
Expand Down Expand Up @@ -450,7 +460,9 @@ Since the Node.js runtime doesn't guarantee that asynchronous functions are dete
{{% codetab %}}

```go
// Do this!!
// Do this!
task := ctx.CallActivity(DoSomething)
task.Await(nil)
```

{{% /codetab %}}
Expand Down Expand Up @@ -489,4 +501,4 @@ To work around these constraints:
- [JavaScript](https://github.com/dapr/js-sdk/tree/main/examples/workflow)
- [.NET](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow)
- [Java](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/workflows)
- [Go](https://github.com/dapr/go-sdk/tree/main/examples/workflow/README.md)
- [Go](https://github.com/dapr/go-sdk/tree/main/examples/workflow/README.md)

0 comments on commit 19d807b

Please sign in to comment.