Skip to content

Commit

Permalink
simply and clean some code
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <[email protected]>
  • Loading branch information
CabinfeverB committed Nov 28, 2023
1 parent 82ace6f commit bc263ed
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
4 changes: 1 addition & 3 deletions client/pd_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ type ServiceDiscovery interface {
GetKeyspaceID() uint32
// GetKeyspaceGroupID returns the ID of the keyspace group
GetKeyspaceGroupID() uint32
// DiscoverServiceURLs discovers the microservice with the specified type and returns the server urls.
DiscoverMicroservice(svcType serviceType) ([]string, error)
// GetServiceURLs returns the URLs of the servers providing the service
GetServiceURLs() []string
// GetServingEndpointClientConn returns the grpc client connection of the serving endpoint
Expand Down Expand Up @@ -324,7 +322,7 @@ func (c *pdServiceDiscovery) GetKeyspaceGroupID() uint32 {
}

// DiscoverMicroservice discovers the microservice with the specified type and returns the server urls.
func (c *pdServiceDiscovery) DiscoverMicroservice(svcType serviceType) (urls []string, err error) {
func (c *pdServiceDiscovery) discoverMicroservice(svcType serviceType) (urls []string, err error) {
switch svcType {
case apiService:
urls = c.GetServiceURLs()
Expand Down
17 changes: 1 addition & 16 deletions client/tso_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,6 @@ func (c *tsoServiceDiscovery) GetKeyspaceGroupID() uint32 {
return c.keyspaceGroupSD.group.Id
}

// DiscoverServiceURLs discovers the microservice with the specified type and returns the server urls.
func (c *tsoServiceDiscovery) DiscoverMicroservice(svcType serviceType) ([]string, error) {
var urls []string

switch svcType {
case apiService:
case tsoService:
return c.apiSvcDiscovery.DiscoverMicroservice(tsoService)
default:
panic("invalid service type")
}

return urls, nil
}

// GetServiceURLs returns the URLs of the tso primary/secondary addresses of this keyspace group.
// For testing use. It should only be called when the client is closed.
func (c *tsoServiceDiscovery) GetServiceURLs() []string {
Expand Down Expand Up @@ -582,7 +567,7 @@ func (c *tsoServiceDiscovery) getTSOServer(sd ServiceDiscovery) (string, error)
)
t := c.tsoServerDiscovery
if len(t.addrs) == 0 || t.failureCount == len(t.addrs) {
addrs, err = sd.DiscoverMicroservice(tsoService)
addrs, err = sd.(*pdServiceDiscovery).discoverMicroservice(tsoService)
if err != nil {
return "", err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/utils/grpcutil/grpcutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func GetForwardedHost(ctx context.Context) string {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
log.Debug("failed to get forwarding metadata")
return ""
}
if t, ok := md[ForwardMetadataKey]; ok {
return t[0]
Expand Down
1 change: 1 addition & 0 deletions server/config/persist_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ func (o *PersistOptions) IsRaftKV2() bool {
}

// SetRegionBucketEnabled sets if the region bucket is enabled.
// only used for test.
func (o *PersistOptions) SetRegionBucketEnabled(enabled bool) {
cfg := o.GetStoreConfig().Clone()
cfg.SetRegionBucketEnabled(enabled)
Expand Down

0 comments on commit bc263ed

Please sign in to comment.