Skip to content

Commit

Permalink
use copy
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng committed Dec 6, 2024
1 parent c06e2b3 commit cccbf89
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions service/interpreter/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package interpreter

import (
"fmt"
"go.temporal.io/sdk/workflow"
"golang.org/x/exp/constraints"
"path/filepath"
"runtime"
"slices"
)

func caller(skip int) string {
Expand All @@ -23,7 +23,12 @@ func LastCaller() string {
// DeterministicKeys returns the keys of a map in deterministic (sorted) order. To be used in for
// loops in workflows for deterministic iteration.
func DeterministicKeys[K constraints.Ordered, V any](m map[K]V) []K {
// see https://github.com/temporalio/sdk-go/blob/7828e06cf517dd2d27881a33efaaf4ff985f2e14/workflow/workflow.go#L787
// copy from https://github.com/temporalio/sdk-go/blob/7828e06cf517dd2d27881a33efaaf4ff985f2e14/workflow/workflow.go#L787
// and example usage https://github.com/temporalio/samples-go/blob/c69dc0bacc78163a50465c6f80aa678739673a4d/safe_message_handler/workflow.go#L119
return workflow.DeterministicKeys(m)
r := make([]K, 0, len(m))
for k := range m {
r = append(r, k)
}
slices.Sort(r)
return r
}

0 comments on commit cccbf89

Please sign in to comment.