Skip to content

Commit

Permalink
pdms: change get ms members return value (#5547)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuSharp authored Feb 19, 2024
1 parent e755e2a commit d7861a6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkg/pdapi/pdapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type PDClient interface {
GetAutoscalingPlans(strategy Strategy) ([]Plan, error)
// GetRecoveringMark return the pd recovering mark
GetRecoveringMark() (bool, error)
// GetMSMembers returns all PD members from cluster by micro service
// GetMSMembers returns all PD members service-addr from cluster by specific Micro Service
GetMSMembers(service string) ([]string, error)
}

Expand Down Expand Up @@ -198,6 +198,15 @@ type MembersInfo struct {
EtcdLeader *pdpb.Member `json:"etcd_leader,omitempty"`
}

// ServiceRegistryEntry is the registry entry of PD Micro Service
type ServiceRegistryEntry struct {
ServiceAddr string `json:"service-addr"`
Version string `json:"version"`
GitHash string `json:"git-hash"`
DeployPath string `json:"deploy-path"`
StartTimestamp int64 `json:"start-timestamp"`
}

// below copied from github.com/tikv/pd/pkg/autoscaling

// Strategy within an HTTP request provides rules and resources to help make decision for auto scaling.
Expand Down Expand Up @@ -320,12 +329,16 @@ func (c *pdClient) GetMSMembers(service string) ([]string, error) {
if err != nil {
return nil, err
}
var members []string
var members []ServiceRegistryEntry
err = json.Unmarshal(body, &members)
if err != nil {
return nil, err
}
return members, nil
var addrs []string
for _, member := range members {
addrs = append(addrs, member.ServiceAddr)
}
return addrs, nil
}

func (c *pdClient) getStores(apiURL string) (*StoresInfo, error) {
Expand Down

0 comments on commit d7861a6

Please sign in to comment.