diff --git a/clients/naming_client/naming_grpc/naming_grpc_proxy.go b/clients/naming_client/naming_grpc/naming_grpc_proxy.go index 9f791788..83bfb084 100644 --- a/clients/naming_client/naming_grpc/naming_grpc_proxy.go +++ b/clients/naming_client/naming_grpc/naming_grpc_proxy.go @@ -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 diff --git a/common/remote/rpc/rpc_request/naming_request.go b/common/remote/rpc/rpc_request/naming_request.go index b03cd4e7..c54e943f 100644 --- a/common/remote/rpc/rpc_request/naming_request.go +++ b/common/remote/rpc/rpc_request/naming_request.go @@ -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, } diff --git a/example/service/main.go b/example/service/main.go index a07dac97..8a16c10d 100644 --- a/example/service/main.go +++ b/example/service/main.go @@ -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 @@ -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", @@ -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) diff --git a/vo/service_param.go b/vo/service_param.go index f68e13ee..35387ccd 100644 --- a/vo/service_param.go +++ b/vo/service_param.go @@ -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 {