From 6f12b4cef9233396c9a4f1ec2345a5a8f39e2001 Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Fri, 7 Jul 2023 12:25:23 +0800 Subject: [PATCH] use KeyspaceGroupPrimaryPath Signed-off-by: lhy1024 --- pkg/keyspace/tso_keyspace_group.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/keyspace/tso_keyspace_group.go b/pkg/keyspace/tso_keyspace_group.go index d319798738b..8ec473add79 100644 --- a/pkg/keyspace/tso_keyspace_group.go +++ b/pkg/keyspace/tso_keyspace_group.go @@ -17,7 +17,6 @@ package keyspace import ( "context" "encoding/json" - "fmt" "sort" "strconv" "strings" @@ -1024,14 +1023,10 @@ func (m *GroupManager) GetKeyspaceGroupPrimaryByID(id uint32) (string, error) { return "", ErrKeyspaceGroupNotExists(id) } - // default keyspace group: "/ms/{cluster_id}/tso/00000/primary". - // non-default keyspace group: "/ms/{cluster_id}/tso/keyspace_groups/election/{group}/primary". - path := fmt.Sprintf("/ms/%d/tso/00000/primary", m.clusterID) - if id != utils.DefaultKeyspaceGroupID { - path = fmt.Sprintf("/ms/%d/tso/keyspace_groups/election/%05d/primary", m.clusterID, id) - } + rootPath := endpoint.TSOSvcRootPath(m.clusterID) + primaryPath := endpoint.KeyspaceGroupPrimaryPath(rootPath, id) leader := &tsopb.Participant{} - ok, _, err := etcdutil.GetProtoMsgWithModRev(m.client, path, leader) + ok, _, err := etcdutil.GetProtoMsgWithModRev(m.client, primaryPath, leader) if err != nil { return "", err }