From 8c75085d6f79134ee3929567f1a2d2e9921cce2f Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Wed, 15 Jan 2025 20:57:09 +0100 Subject: [PATCH] Add .String() func Signed-off-by: Tim Vaillancourt --- go/vt/topo/wildcards.go | 5 +++++ go/vt/vtorc/logic/tablet_discovery.go | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go/vt/topo/wildcards.go b/go/vt/topo/wildcards.go index c2921be1d19..d66baf1673f 100644 --- a/go/vt/topo/wildcards.go +++ b/go/vt/topo/wildcards.go @@ -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" @@ -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: diff --git a/go/vt/vtorc/logic/tablet_discovery.go b/go/vt/vtorc/logic/tablet_discovery.go index e6a1e521856..6b8860e1788 100644 --- a/go/vt/vtorc/logic/tablet_discovery.go +++ b/go/vt/vtorc/logic/tablet_discovery.go @@ -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