Skip to content

Commit a71c4c0

Browse files
[GithubActions] Update false false false SDK-Go 0.21.0 false false (#357)
Co-authored-by: gvdongen <gvdongen@users.noreply.github.com>
1 parent ad2a114 commit a71c4c0

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

go/templates/go/.claude/CLAUDE.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,18 @@ if err != nil {
210210
❌ Never use `rand.Float64()` - non-deterministic and breaks replay logic.
211211
✅ Use `restate.Rand()` or `restate.UUID()` - Restate journals the result for deterministic replay.
212212

213+
```go {"CODE_LOAD::go/develop/journalingresults.go#uuid"} theme={null}
214+
uuid := restate.UUID(ctx)
215+
```
216+
217+
```go {"CODE_LOAD::go/develop/journalingresults.go#random_nb"} theme={null}
218+
randomInt := restate.Rand(ctx).Uint64()
219+
randomFloat := restate.Rand(ctx).Float64()
220+
mathRandV2 := rand.New(restate.RandSource(ctx))
221+
```
222+
213223
❌ Never use `time.Now()` - returns different values during replay.
214-
Use `restate.Now()` - Restate records and replays the same timestamp.
224+
Wrap `time.Now()` in `restate.Run` to let Restate record the timestamp.
215225

216226
### Durable Timers and Sleep
217227

@@ -276,16 +286,19 @@ if err != nil {
276286

277287
## Concurrency
278288

279-
Always use Restate combinators (`restate.Select`) instead of Go's native goroutines and channels - they journal execution order for deterministic replay.
289+
Always use Restate `Wait*` functions instead of Go's native goroutines and channels - they journal execution order for deterministic replay.
280290

281291
### Select the first successful completion
282292

283293
```go {"CODE_LOAD::go/develop/journalingresults.go#race"} theme={null}
284294
sleepFuture := restate.After(ctx, 30*time.Second)
285295
callFuture := restate.Service[string](ctx, "MyService", "MyHandler").RequestFuture("hi")
286296

287-
selector := restate.Select(ctx, sleepFuture, callFuture)
288-
switch selector.Select() {
297+
fut, err := restate.WaitFirst(ctx, sleepFuture, callFuture)
298+
if err != nil {
299+
return "", err
300+
}
301+
switch fut {
289302
case sleepFuture:
290303
if err := sleepFuture.Done(); err != nil {
291304
return "", err
@@ -300,20 +313,19 @@ case callFuture:
300313
}
301314
```
302315

303-
Select blocks on the next completed operation or returns `nil` if there are none left.
304-
305316
### Wait for all tasks to complete
306317

307318
```go {"CODE_LOAD::go/develop/journalingresults.go#all"} theme={null}
308319
callFuture1 := restate.Service[string](ctx, "MyService", "MyHandler").RequestFuture("hi")
309320
callFuture2 := restate.Service[string](ctx, "MyService", "MyHandler").RequestFuture("hi again")
310321

311-
selector := restate.Select(ctx, callFuture1, callFuture2)
312-
313322
// Collect all results
314323
var subResults []string
315-
for selector.Remaining() {
316-
response, err := selector.Select().(restate.ResponseFuture[string]).Response()
324+
for fut, err := range restate.Wait(ctx, callFuture1, callFuture2) {
325+
if err != nil {
326+
return "", err
327+
}
328+
response, err := fut.(restate.ResponseFuture[string]).Response()
317329
if err != nil {
318330
return "", err
319331
}

go/templates/go/.cursor/rules/AGENTS.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,18 @@ if err != nil {
210210
❌ Never use `rand.Float64()` - non-deterministic and breaks replay logic.
211211
✅ Use `restate.Rand()` or `restate.UUID()` - Restate journals the result for deterministic replay.
212212

213+
```go {"CODE_LOAD::go/develop/journalingresults.go#uuid"} theme={null}
214+
uuid := restate.UUID(ctx)
215+
```
216+
217+
```go {"CODE_LOAD::go/develop/journalingresults.go#random_nb"} theme={null}
218+
randomInt := restate.Rand(ctx).Uint64()
219+
randomFloat := restate.Rand(ctx).Float64()
220+
mathRandV2 := rand.New(restate.RandSource(ctx))
221+
```
222+
213223
❌ Never use `time.Now()` - returns different values during replay.
214-
Use `restate.Now()` - Restate records and replays the same timestamp.
224+
Wrap `time.Now()` in `restate.Run` to let Restate record the timestamp.
215225

216226
### Durable Timers and Sleep
217227

@@ -276,16 +286,19 @@ if err != nil {
276286

277287
## Concurrency
278288

279-
Always use Restate combinators (`restate.Select`) instead of Go's native goroutines and channels - they journal execution order for deterministic replay.
289+
Always use Restate `Wait*` functions instead of Go's native goroutines and channels - they journal execution order for deterministic replay.
280290

281291
### Select the first successful completion
282292

283293
```go {"CODE_LOAD::go/develop/journalingresults.go#race"} theme={null}
284294
sleepFuture := restate.After(ctx, 30*time.Second)
285295
callFuture := restate.Service[string](ctx, "MyService", "MyHandler").RequestFuture("hi")
286296

287-
selector := restate.Select(ctx, sleepFuture, callFuture)
288-
switch selector.Select() {
297+
fut, err := restate.WaitFirst(ctx, sleepFuture, callFuture)
298+
if err != nil {
299+
return "", err
300+
}
301+
switch fut {
289302
case sleepFuture:
290303
if err := sleepFuture.Done(); err != nil {
291304
return "", err
@@ -300,20 +313,19 @@ case callFuture:
300313
}
301314
```
302315

303-
Select blocks on the next completed operation or returns `nil` if there are none left.
304-
305316
### Wait for all tasks to complete
306317

307318
```go {"CODE_LOAD::go/develop/journalingresults.go#all"} theme={null}
308319
callFuture1 := restate.Service[string](ctx, "MyService", "MyHandler").RequestFuture("hi")
309320
callFuture2 := restate.Service[string](ctx, "MyService", "MyHandler").RequestFuture("hi again")
310321

311-
selector := restate.Select(ctx, callFuture1, callFuture2)
312-
313322
// Collect all results
314323
var subResults []string
315-
for selector.Remaining() {
316-
response, err := selector.Select().(restate.ResponseFuture[string]).Response()
324+
for fut, err := range restate.Wait(ctx, callFuture1, callFuture2) {
325+
if err != nil {
326+
return "", err
327+
}
328+
response, err := fut.(restate.ResponseFuture[string]).Response()
317329
if err != nil {
318330
return "", err
319331
}

0 commit comments

Comments
 (0)