Skip to content

Commit c64d661

Browse files
committed
chore: replace x/exp/maps with maps
Pretty straightforward, except that `import "maps"` returns a sequence rather than a slice, so all this also needs `slices.Collect`. That seems minor enough to be worth the switch though. Signed-off-by: Steven L <[email protected]>
1 parent 1f49d66 commit c64d661

File tree

15 files changed

+54
-57
lines changed

15 files changed

+54
-57
lines changed

client/history/peer_resolver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package history
2222

2323
import (
2424
"errors"
25+
"maps"
2526
"slices"
2627
"testing"
2728

@@ -30,7 +31,6 @@ import (
3031
"github.com/stretchr/testify/require"
3132
"github.com/uber/ringpop-go/hashring"
3233
gomock "go.uber.org/mock/gomock"
33-
"golang.org/x/exp/maps"
3434

3535
"github.com/uber/cadence/common"
3636
"github.com/uber/cadence/common/membership"
@@ -295,7 +295,7 @@ func TestPeerResolver(t *testing.T) {
295295

296296
// small sanity check: sharded response should return all inputs
297297
assertAllKeysPresent := func(t *testing.T, sharded map[Peer][]string, limits []string) {
298-
responded := maps.Values(sharded)
298+
responded := slices.Collect(maps.Values(sharded))
299299
assert.ElementsMatchf(t,
300300
limits,
301301
slices.Concat(responded...), // flatten the [][]string

common/archiver/gcloud/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0
359359
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
360360
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
361361
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
362-
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4=
363-
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
364362
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=
365363
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
366364
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

common/metrics/config_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package metrics
22

33
import (
4+
"maps"
45
"testing"
5-
6-
"golang.org/x/exp/maps"
76
)
87

98
func TestHistogramMigrationMetricsExist(t *testing.T) {

common/quotas/global/algorithm/requestweighted_fuzz_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ package algorithm
2424

2525
import (
2626
"encoding/binary"
27+
"maps"
2728
"math"
29+
"slices"
2830
"testing"
2931
"time"
3032

31-
"golang.org/x/exp/maps"
32-
"golang.org/x/exp/slices"
33-
3433
"github.com/uber/cadence/common/dynamicconfig/dynamicproperties"
3534
"github.com/uber/cadence/common/log/testlogger"
3635
"github.com/uber/cadence/common/metrics"
@@ -114,8 +113,8 @@ func FuzzMultiUpdate(f *testing.F) {
114113
t.Error("no keys")
115114
}
116115

117-
keys := maps.Keys(keySet)
118-
idents := maps.Keys(identSet)
116+
keys := slices.Collect(maps.Keys(keySet))
117+
idents := slices.Collect(maps.Keys(identSet))
119118
slices.Sort(keys)
120119
slices.Sort(idents)
121120

common/quotas/global/algorithm/requestweighted_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ package algorithm
2424

2525
import (
2626
"fmt"
27+
"maps"
2728
"math"
2829
"math/rand"
30+
"slices"
2931
"strings"
3032
"sync"
3133
"testing"
@@ -35,7 +37,6 @@ import (
3537
"github.com/stretchr/testify/require"
3638
"github.com/uber-go/tally"
3739
"go.uber.org/multierr"
38-
"golang.org/x/exp/maps"
3940

4041
"github.com/uber/cadence/common"
4142
"github.com/uber/cadence/common/clock"
@@ -591,7 +592,7 @@ func TestConcurrent(t *testing.T) {
591592
err := agg.Update(UpdateParams{ID: host, Load: updates, Elapsed: updateRate})
592593
require.NoError(t, err)
593594
} else {
594-
_, err := agg.HostUsage(host, maps.Keys(updates))
595+
_, err := agg.HostUsage(host, slices.Collect(maps.Keys(updates)))
595596
require.NoError(t, err)
596597
}
597598
}
@@ -1022,7 +1023,7 @@ func BenchmarkNormalUse(b *testing.B) {
10221023
rounds = append(rounds, round{
10231024
host: Identity(fmt.Sprintf("host %d", rand.Intn(hosts))),
10241025
load: reqs,
1025-
keys: maps.Keys(reqs),
1026+
keys: slices.Collect(maps.Keys(reqs)),
10261027
elapsed: time.Duration(rand.Int63n(updateRate.Nanoseconds())),
10271028
})
10281029
}

common/quotas/global/rpc/client_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ import (
2626
"context"
2727
"errors"
2828
"fmt"
29+
"maps"
2930
"math"
3031
"reflect"
32+
"slices"
3133
"testing"
3234
"time"
3335

3436
"github.com/stretchr/testify/assert"
3537
"go.uber.org/mock/gomock"
3638
"go.uber.org/yarpc"
37-
"golang.org/x/exp/maps"
3839

3940
"github.com/uber/cadence/client/history"
4041
"github.com/uber/cadence/common/log/testlogger"
@@ -179,7 +180,7 @@ func (a matchrequest) Matches(x interface{}) bool {
179180
keys[k] = struct{}{}
180181
}
181182
gotKeys := map[string]struct{}{}
182-
for _, k := range stringy(maps.Keys(up.Load)) {
183+
for _, k := range stringy(slices.Collect(maps.Keys(up.Load))) {
183184
gotKeys[k] = struct{}{}
184185
}
185186
a.t.Logf("want keys: %v, got keys: %v", maps.Keys(keys), maps.Keys(gotKeys))

common/util_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ import (
2626
"context"
2727
"errors"
2828
"fmt"
29+
"maps"
2930
"math/rand"
3031
"reflect"
3132
"runtime"
33+
"slices"
3234
"strconv"
3335
"sync"
3436
"testing"
@@ -40,7 +42,6 @@ import (
4042
"github.com/uber-go/tally"
4143
"go.uber.org/mock/gomock"
4244
"go.uber.org/yarpc/yarpcerrors"
43-
"golang.org/x/exp/maps"
4445

4546
"github.com/uber/cadence/common/backoff"
4647
"github.com/uber/cadence/common/constants"
@@ -1653,7 +1654,7 @@ func TestCheckEventBlobSizeLimit(t *testing.T) {
16531654
assertMetrics: func(snapshot tally.Snapshot) {
16541655
counters := snapshot.Counters()
16551656
assert.Len(t, counters, 1)
1656-
values := maps.Values(counters)
1657+
values := slices.Collect(maps.Values(counters))
16571658
assert.Equal(t, "test.blob_size_exceed_limit", values[0].Name())
16581659
assert.Equal(t, int64(1), values[0].Value())
16591660
},

service/history/decision/checker_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
package decision
2424

2525
import (
26-
"sort"
26+
"maps"
27+
"slices"
2728
"testing"
2829
"time"
2930

@@ -33,7 +34,6 @@ import (
3334
"github.com/uber-go/tally"
3435
"go.uber.org/mock/gomock"
3536
"go.uber.org/zap/zaptest/observer"
36-
"golang.org/x/exp/maps"
3737

3838
"github.com/uber/cadence/common"
3939
"github.com/uber/cadence/common/cache"
@@ -795,7 +795,7 @@ func TestWorkflowSizeChecker_failWorkflowIfBlobSizeExceedsLimit(t *testing.T) {
795795
assertLogsAndMetrics: func(t *testing.T, logs *observer.ObservedLogs, scope tally.TestScope) {
796796
assert.Empty(t, logs.All())
797797
// ensure metrics with the size is emitted.
798-
timerData := maps.Values(scope.Snapshot().Timers())
798+
timerData := slices.Collect(maps.Values(scope.Snapshot().Timers()))
799799
assert.Len(t, timerData, 2)
800800
assert.Equal(t, "test.event_blob_size", timerData[0].Name())
801801
},
@@ -887,13 +887,13 @@ func TestWorkflowSizeChecker_failWorkflowSizeExceedsLimit(t *testing.T) {
887887
assertLogsAndMetrics: func(t *testing.T, logs *observer.ObservedLogs, scope tally.TestScope) {
888888
assert.Empty(t, logs.All())
889889
// ensure metrics with the size is emitted.
890-
timerData := maps.Values(scope.Snapshot().Timers())
890+
timerData := slices.Collect(maps.Values(scope.Snapshot().Timers()))
891891
assert.Len(t, timerData, 4)
892892
timerNames := make([]string, 0, 4)
893893
for _, timer := range timerData {
894894
timerNames = append(timerNames, timer.Name())
895895
}
896-
sort.Strings(timerNames)
896+
slices.Sort(timerNames)
897897

898898
// timers are duplicated for specific domain and domain: all
899899
assert.Equal(t, []string{"test.history_count", "test.history_count", "test.history_size", "test.history_size"}, timerNames)

service/history/execution/mutable_state_builder.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ package execution
2424
import (
2525
"context"
2626
"fmt"
27+
"maps"
2728
"math/rand"
2829
"runtime/debug"
30+
"slices"
2931
"time"
3032

3133
"github.com/pborman/uuid"
32-
"golang.org/x/exp/maps"
3334

3435
"github.com/uber/cadence/common"
3536
"github.com/uber/cadence/common/backoff"
@@ -1486,18 +1487,18 @@ func (e *mutableStateBuilder) CloseTransactionAsMutation(
14861487
ExecutionInfo: e.executionInfo,
14871488
VersionHistories: e.versionHistories,
14881489

1489-
UpsertActivityInfos: maps.Values(e.updateActivityInfos),
1490-
DeleteActivityInfos: maps.Keys(e.deleteActivityInfos),
1491-
UpsertTimerInfos: maps.Values(e.updateTimerInfos),
1492-
DeleteTimerInfos: maps.Keys(e.deleteTimerInfos),
1493-
UpsertChildExecutionInfos: maps.Values(e.updateChildExecutionInfos),
1494-
DeleteChildExecutionInfos: maps.Keys(e.deleteChildExecutionInfos),
1495-
UpsertRequestCancelInfos: maps.Values(e.updateRequestCancelInfos),
1496-
DeleteRequestCancelInfos: maps.Keys(e.deleteRequestCancelInfos),
1497-
UpsertSignalInfos: maps.Values(e.updateSignalInfos),
1498-
DeleteSignalInfos: maps.Keys(e.deleteSignalInfos),
1499-
UpsertSignalRequestedIDs: maps.Keys(e.updateSignalRequestedIDs),
1500-
DeleteSignalRequestedIDs: maps.Keys(e.deleteSignalRequestedIDs),
1490+
UpsertActivityInfos: slices.Collect(maps.Values(e.updateActivityInfos)),
1491+
DeleteActivityInfos: slices.Collect(maps.Keys(e.deleteActivityInfos)),
1492+
UpsertTimerInfos: slices.Collect(maps.Values(e.updateTimerInfos)),
1493+
DeleteTimerInfos: slices.Collect(maps.Keys(e.deleteTimerInfos)),
1494+
UpsertChildExecutionInfos: slices.Collect(maps.Values(e.updateChildExecutionInfos)),
1495+
DeleteChildExecutionInfos: slices.Collect(maps.Keys(e.deleteChildExecutionInfos)),
1496+
UpsertRequestCancelInfos: slices.Collect(maps.Values(e.updateRequestCancelInfos)),
1497+
DeleteRequestCancelInfos: slices.Collect(maps.Keys(e.deleteRequestCancelInfos)),
1498+
UpsertSignalInfos: slices.Collect(maps.Values(e.updateSignalInfos)),
1499+
DeleteSignalInfos: slices.Collect(maps.Keys(e.deleteSignalInfos)),
1500+
UpsertSignalRequestedIDs: slices.Collect(maps.Keys(e.updateSignalRequestedIDs)),
1501+
DeleteSignalRequestedIDs: slices.Collect(maps.Keys(e.deleteSignalRequestedIDs)),
15011502
NewBufferedEvents: e.updateBufferedEvents,
15021503
ClearBufferedEvents: e.clearBufferedEvents,
15031504

@@ -1575,12 +1576,12 @@ func (e *mutableStateBuilder) CloseTransactionAsSnapshot(
15751576
ExecutionInfo: e.executionInfo,
15761577
VersionHistories: e.versionHistories,
15771578

1578-
ActivityInfos: maps.Values(e.pendingActivityInfoIDs),
1579-
TimerInfos: maps.Values(e.pendingTimerInfoIDs),
1580-
ChildExecutionInfos: maps.Values(e.pendingChildExecutionInfoIDs),
1581-
RequestCancelInfos: maps.Values(e.pendingRequestCancelInfoIDs),
1582-
SignalInfos: maps.Values(e.pendingSignalInfoIDs),
1583-
SignalRequestedIDs: maps.Keys(e.pendingSignalRequestedIDs),
1579+
ActivityInfos: slices.Collect(maps.Values(e.pendingActivityInfoIDs)),
1580+
TimerInfos: slices.Collect(maps.Values(e.pendingTimerInfoIDs)),
1581+
ChildExecutionInfos: slices.Collect(maps.Values(e.pendingChildExecutionInfoIDs)),
1582+
RequestCancelInfos: slices.Collect(maps.Values(e.pendingRequestCancelInfoIDs)),
1583+
SignalInfos: slices.Collect(maps.Values(e.pendingSignalInfoIDs)),
1584+
SignalRequestedIDs: slices.Collect(maps.Keys(e.pendingSignalRequestedIDs)),
15841585

15851586
TasksByCategory: map[persistence.HistoryTaskCategory][]persistence.Task{
15861587
persistence.HistoryTaskCategoryTransfer: e.insertTransferTasks,

service/history/execution/mutable_state_util_test_helpers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ package execution
2424

2525
import (
2626
"encoding/json"
27+
"slices"
2728
"testing"
2829

29-
"golang.org/x/exp/slices"
30-
3130
"github.com/uber/cadence/common/cache"
3231
"github.com/uber/cadence/common/persistence"
3332
"github.com/uber/cadence/common/types"

0 commit comments

Comments
 (0)