Skip to content

Commit

Permalink
fix QueryInstancesOfService clusters (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
binbin0325 authored Feb 22, 2023
1 parent e190e29 commit 82a862a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions clients/naming_client/naming_grpc/naming_grpc_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func (proxy *NamingGrpcProxy) ServerHealthy() bool {
}

// QueryInstancesOfService ...
func (proxy *NamingGrpcProxy) QueryInstancesOfService(serviceName, groupName, clusters string, udpPort int, healthyOnly bool) (*model.Service, error) {
response, err := proxy.requestToServer(rpc_request.NewServiceQueryRequest(proxy.clientConfig.NamespaceId, serviceName, groupName, clusters,
func (proxy *NamingGrpcProxy) QueryInstancesOfService(serviceName, groupName, cluster string, udpPort int, healthyOnly bool) (*model.Service, error) {
response, err := proxy.requestToServer(rpc_request.NewServiceQueryRequest(proxy.clientConfig.NamespaceId, serviceName, groupName, cluster,
healthyOnly, udpPort))
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions common/remote/rpc/rpc_request/naming_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ func (r *SubscribeServiceRequest) GetRequestType() string {

type ServiceQueryRequest struct {
*NamingRequest
Clusters string `json:"clusters"`
Cluster string `json:"cluster"`
HealthyOnly bool `json:"healthyOnly"`
UdpPort int `json:"udpPort"`
}

func NewServiceQueryRequest(namespace, serviceName, groupName, clusters string, healthyOnly bool, udpPort int) *ServiceQueryRequest {
func NewServiceQueryRequest(namespace, serviceName, groupName, cluster string, healthyOnly bool, udpPort int) *ServiceQueryRequest {
return &ServiceQueryRequest{
NamingRequest: NewNamingRequest(namespace, serviceName, groupName),
Clusters: clusters,
Cluster: cluster,
HealthyOnly: healthyOnly,
UdpPort: udpPort,
}
Expand Down
5 changes: 3 additions & 2 deletions example/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func main() {
ServiceName: "demo.go",
GroupName: "group-a",
Clusters: []string{"cluster-a"},
HealthyOnly: true,
})

//SelectOneHealthyInstance return one instance by WRR strategy for load balance
Expand All @@ -154,7 +155,7 @@ func main() {
//wait for client pull change from server
time.Sleep(3 * time.Second)

/*updateServiceInstance(client, vo.UpdateInstanceParam{
updateServiceInstance(client, vo.UpdateInstanceParam{
Ip: "10.0.0.11", //update ip
Port: 8848,
ServiceName: "demo.go",
Expand All @@ -165,7 +166,7 @@ func main() {
Healthy: true,
Ephemeral: true,
Metadata: map[string]string{"idc": "beijing1"}, //update metadata
})*/
})

//wait for client pull change from server
time.Sleep(3 * time.Second)
Expand Down
2 changes: 1 addition & 1 deletion vo/service_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type SelectInstancesParam struct {
Clusters []string `param:"clusters"` //optional
ServiceName string `param:"serviceName"` //required
GroupName string `param:"groupName"` //optional,default:DEFAULT_GROUP
HealthyOnly bool `param:"healthyOnly"` //optional,return only healthy instance
HealthyOnly bool `param:"healthyOnly"` //optional,value = true return only healthy instance, value = false return only unHealthy instance
}

type SelectOneHealthInstanceParam struct {
Expand Down

0 comments on commit 82a862a

Please sign in to comment.