Skip to content

Commit

Permalink
mcs: Refactor ServicePath to make caller's life easier (tikv#6799)
Browse files Browse the repository at this point in the history
close tikv#6800

Signed-off-by: Xiaoguang Sun <sunxiaoguang@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and rleungx committed Aug 2, 2023
1 parent 1e103df commit 33c2b88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/mcs/discovery/key_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
4 changes: 2 additions & 2 deletions pkg/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 33c2b88

Please sign in to comment.