diff --git a/service/interpreter/utils.go b/service/interpreter/utils.go index 73b8b54b..3782e5f6 100644 --- a/service/interpreter/utils.go +++ b/service/interpreter/utils.go @@ -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 { @@ -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 }