From 6ae87bfe33da253d340054394fdbbe6dfafaedca Mon Sep 17 00:00:00 2001 From: Xiaoguang Sun Date: Fri, 14 Jul 2023 10:33:44 +0800 Subject: [PATCH] mcs: Refactor ServicePath to make caller's life easier (#6799) close tikv/pd#6800 Signed-off-by: Xiaoguang Sun Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- pkg/mcs/discovery/key_path.go | 4 ++-- pkg/tso/keyspace_group_manager_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/mcs/discovery/key_path.go b/pkg/mcs/discovery/key_path.go index d77aa98f3a9..b7bf9d1cac3 100644 --- a/pkg/mcs/discovery/key_path.go +++ b/pkg/mcs/discovery/key_path.go @@ -32,10 +32,10 @@ func RegistryPath(clusterID, serviceName, serviceAddr string) string { // ServicePath returns the path to store microservice addresses. func ServicePath(clusterID, serviceName string) string { - return strings.Join([]string{utils.MicroserviceRootPath, clusterID, serviceName, registryKey}, "/") + return strings.Join([]string{utils.MicroserviceRootPath, clusterID, serviceName, registryKey, ""}, "/") } // TSOPath returns the path to store TSO addresses. func TSOPath(clusterID uint64) string { - return ServicePath(strconv.FormatUint(clusterID, 10), "tso") + "/" + return ServicePath(strconv.FormatUint(clusterID, 10), "tso") } diff --git a/pkg/tso/keyspace_group_manager_test.go b/pkg/tso/keyspace_group_manager_test.go index 600c46348a4..2ffa802b4f3 100644 --- a/pkg/tso/keyspace_group_manager_test.go +++ b/pkg/tso/keyspace_group_manager_test.go @@ -151,7 +151,7 @@ func (suite *keyspaceGroupManagerTestSuite) TestNewKeyspaceGroupManager() { tsoServiceID := &discovery.ServiceRegistryEntry{ServiceAddr: suite.cfg.AdvertiseListenAddr} guid := uuid.New().String() - tsoServiceKey := discovery.ServicePath(guid, "tso") + "/" + tsoServiceKey := discovery.ServicePath(guid, "tso") legacySvcRootPath := path.Join("/pd", guid) tsoSvcRootPath := path.Join(mcsutils.MicroserviceRootPath, guid, "tso") electionNamePrefix := "tso-server-" + guid @@ -817,7 +817,7 @@ func (suite *keyspaceGroupManagerTestSuite) newKeyspaceGroupManager( cfg *TestServiceConfig, ) *KeyspaceGroupManager { tsoServiceID := &discovery.ServiceRegistryEntry{ServiceAddr: cfg.GetAdvertiseListenAddr()} - tsoServiceKey := discovery.ServicePath(uniqueStr, "tso") + "/" + tsoServiceKey := discovery.ServicePath(uniqueStr, "tso") legacySvcRootPath := path.Join("/pd", uniqueStr) tsoSvcRootPath := path.Join(mcsutils.MicroserviceRootPath, uniqueStr, "tso") electionNamePrefix := "kgm-test-" + cfg.GetAdvertiseListenAddr()