Skip to content

Commit d60a2ef

Browse files
authored
perf(go): clarified text around go selectors and activity execution (#4362)
1 parent b42ce23 commit d60a2ef

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

docs/develop/go/selectors.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func SampleWorkflow(ctx workflow.Context) error {
6767

6868
## Use Selectors with Futures
6969

70-
You usually add `Future`s after `Activities`:
70+
You usually add `Futures` after `Activities`:
7171

7272
```go
7373
// API Example: defer code execution until after an activity is done
@@ -77,20 +77,21 @@ selector.AddFuture(work, func(f workflow.Future) {
7777
})
7878
```
7979

80-
`selector.Select(ctx)` is the primary mechanism which blocks on and executes `Future` work.
81-
It is intentionally flexible; you may call it conditionally or multiple times:
80+
Calling `ExecuteActivity` by itself doesn't result in actual Activity execution. It results in a command that gets batched with others when there's a yield point in the Workflow definition. Your `Futures` won't run until you call `selector.Select(ctx)`. So no calls to `ExecuteActivity` should result in commands being sent to the server until `selector.Select` is called.
81+
82+
A call to `selector.Select(ctx)` doesn't actually execute a `Future`, but it _requests_ execution for a `Future`. So this is a point where the SDK will communicate the command to execute the Activity to the server.
8283

8384
```go
84-
// API Example: blocking conditionally
85+
// API Example: blocking conditionally
8586
if somecondition != nil {
86-
selector.Select(ctx)
87+
selector.Select(ctx)
8788
}
8889

89-
// API Example: popping off all remaining Futures
90+
// API Example: popping off all remaining Futures
9091
for i := 0; i < len(someArray); i++ {
91-
selector.Select(ctx) // this will wait for one branch
92-
// you can interrupt execution here
93-
}
92+
selector.Select(ctx) // this will wait for one branch
93+
// you can interrupt execution here
94+
}
9495
```
9596

9697
A Future matches only once per Selector instance even if Select is called multiple times.

0 commit comments

Comments
 (0)