Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdms: change get ms members return value #5547

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading