Skip to content

Commit d0c9f8e

Browse files
committed
perf: diff shards in discovery
1 parent f87b125 commit d0c9f8e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

discovery/discovery.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ func diffShards(old, new Shards) bool {
142142
if len(old) != len(new) {
143143
return true
144144
}
145-
sort.Sort(old)
146-
sort.Sort(new)
145+
// sort.Sort(old)
146+
// sort.Sort(new)
147147
for i := range old {
148148
if diffReplicas(old[i], new[i]) {
149149
return true

discovery/discovery_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@ func TestDiffShards(t *testing.T) {
3737
Replicas{"127.0.0.1:8082", "127.0.0.1:8083"},
3838
Replicas{"127.0.0.1:8081", "127.0.0.1:8080"},
3939
}
40-
assert.Equal(t, false, diffShards(old1, new2))
40+
assert.Equal(t, true, diffShards(old1, new2))
4141

4242
var new3 = Shards{
4343
Replicas{"127.0.0.1:8082", "127.0.0.1:8083"},
4444
Replicas{"127.0.0.2:8081", "127.0.0.1:8080"},
4545
}
4646
assert.Equal(t, true, diffShards(old1, new3))
47+
48+
var new4 = Shards{
49+
Replicas{"127.0.0.1:8081", "127.0.0.1:8080"},
50+
Replicas{"127.0.0.1:8083", "127.0.0.1:8082"},
51+
}
52+
assert.Equal(t, false, diffShards(old1, new4))
4753
}

0 commit comments

Comments
 (0)