Skip to content

Commit

Permalink
feat: use simpler code
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Jan 24, 2025
1 parent c707444 commit b51bcc7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions go/vt/key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func NewKeyRange(start []byte, end []byte) *topodatapb.KeyRange {
// NewCompleteKeyRange returns a complete key range.
func NewCompleteKeyRange() *topodatapb.KeyRange {
return &topodatapb.KeyRange{
Start: []byte{},
End: []byte{},
Start: nil,
End: nil,
}
}

Expand Down
9 changes: 2 additions & 7 deletions go/vt/vtorc/logic/tablet_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,11 @@ func initializeShardsToWatch() error {
return fmt.Errorf("Invalid key range %q while parsing clusters to watch", s)
}
// Parse the shard name into key range value.
_, keyRange, err := topo.ValidateShardName(s)
keyRanges, err := key.ParseShardingSpec(s)
if err != nil {
return fmt.Errorf("Could not parse shard name %q: %+v", s, err)
}
// If the key range is nil, then the user is not using RangeBased Sharding.
// So we want to watch all the shards of the keyspace.
if keyRange == nil {
keyRange = key.NewCompleteKeyRange()
}
shardsToWatch[k] = append(shardsToWatch[k], keyRange)
shardsToWatch[k] = append(shardsToWatch[k], keyRanges...)
} else {
// Remove trailing slash if exists.
ks = strings.TrimSuffix(ks, "/")
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtorc/logic/tablet_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ func TestInitializeShardsToWatch(t *testing.T) {
key.NewCompleteKeyRange(),
},
"test2": {
key.NewKeyRange([]byte{}, []byte{0x80}),
key.NewKeyRange([]byte{0x80}, []byte{}),
key.NewKeyRange(nil, []byte{0x80}),
key.NewKeyRange([]byte{0x80}, nil),
},
},
},
Expand Down

0 comments on commit b51bcc7

Please sign in to comment.