Skip to content

Commit

Permalink
Add .String() func
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
  • Loading branch information
timvaillancourt committed Jan 15, 2025
1 parent 9cfc222 commit 8c75085
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions go/vt/topo/wildcards.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"context"

"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/topo/topoproto"
"vitess.io/vitess/go/vt/vterrors"

"vitess.io/vitess/go/fileutil"
Expand Down Expand Up @@ -64,6 +65,10 @@ type KeyspaceShard struct {
Shard string
}

func (ks KeyspaceShard) String() string {
return topoproto.KeyspaceShardString(ks.Keyspace, ks.Shard)
}

// ResolveShardWildcard will resolve shard wildcards. Both keyspace and shard
// names can use wildcard. Errors talking to the topology server are returned.
// ErrNoNode is ignored if it's the result of resolving a wildcard. Examples:
Expand Down
5 changes: 1 addition & 4 deletions go/vt/vtorc/logic/tablet_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ func getKeyspaceShardsToWatch() ([]*topo.KeyspaceShard, error) {
}

slices.SortStableFunc(keyspaceShards, func(a, b *topo.KeyspaceShard) int {
return strings.Compare(
topoproto.KeyspaceShardString(a.Keyspace, a.Shard),
topoproto.KeyspaceShardString(b.Keyspace, b.Shard),
)
return strings.Compare(a.String(), b.String())
})

return keyspaceShards, nil
Expand Down

0 comments on commit 8c75085

Please sign in to comment.