AlexStocks commented on a change in pull request #1161:
URL: https://github.com/apache/dubbo-go/pull/1161#discussion_r615307751
##########
File path: registry/service_instance.go
##########
@@ -88,6 +115,63 @@ func (d *DefaultServiceInstance) IsHealthy() bool {
return d.Healthy
}
+func (d *DefaultServiceInstance) GetAddress() string {
Review comment:
pls add comment
##########
File path: registry/service_instance.go
##########
@@ -88,6 +115,63 @@ func (d *DefaultServiceInstance) IsHealthy() bool {
return d.Healthy
}
+func (d *DefaultServiceInstance) GetAddress() string {
+ if d.Address != "" {
+ return d.Address
+ }
+ if d.Port <= 0 {
+ d.Address = d.Host
+ } else {
+ d.Address = d.Host + ":" + strconv.Itoa(d.Port)
+ }
+ return d.Address
+}
+
+func (d *DefaultServiceInstance) SetServiceMetadata(m *common.MetadataInfo) {
+ d.ServiceMetadata = m
+}
Review comment:
pls add comment
##########
File path: registry/service_instance.go
##########
@@ -88,6 +115,63 @@ func (d *DefaultServiceInstance) IsHealthy() bool {
return d.Healthy
}
+func (d *DefaultServiceInstance) GetAddress() string {
+ if d.Address != "" {
+ return d.Address
+ }
+ if d.Port <= 0 {
+ d.Address = d.Host
+ } else {
+ d.Address = d.Host + ":" + strconv.Itoa(d.Port)
+ }
+ return d.Address
+}
+
+func (d *DefaultServiceInstance) SetServiceMetadata(m *common.MetadataInfo) {
+ d.ServiceMetadata = m
+}
+
+// ToURLs
+func (d *DefaultServiceInstance) ToURLs() []*common.URL {
+ urls := make([]*common.URL, 0, 8)
+ for _, service := range d.ServiceMetadata.Services {
+ url :=
common.NewURLWithOptions(common.WithProtocol(service.Protocol),
+ common.WithIp(d.Host),
common.WithPort(strconv.Itoa(d.Port)),
+ common.WithMethods(service.GetMethods()),
common.WithParams(service.GetParams()))
+ urls = append(urls, url)
+ }
+ return urls
+}
+
+func (d *DefaultServiceInstance) GetEndPoints() []*Endpoint {
Review comment:
pls add comment
##########
File path: registry/service_instance.go
##########
@@ -88,6 +115,63 @@ func (d *DefaultServiceInstance) IsHealthy() bool {
return d.Healthy
}
+func (d *DefaultServiceInstance) GetAddress() string {
+ if d.Address != "" {
+ return d.Address
+ }
+ if d.Port <= 0 {
+ d.Address = d.Host
+ } else {
+ d.Address = d.Host + ":" + strconv.Itoa(d.Port)
+ }
+ return d.Address
+}
+
+func (d *DefaultServiceInstance) SetServiceMetadata(m *common.MetadataInfo) {
+ d.ServiceMetadata = m
+}
+
+// ToURLs
+func (d *DefaultServiceInstance) ToURLs() []*common.URL {
+ urls := make([]*common.URL, 0, 8)
+ for _, service := range d.ServiceMetadata.Services {
+ url :=
common.NewURLWithOptions(common.WithProtocol(service.Protocol),
+ common.WithIp(d.Host),
common.WithPort(strconv.Itoa(d.Port)),
+ common.WithMethods(service.GetMethods()),
common.WithParams(service.GetParams()))
+ urls = append(urls, url)
+ }
+ return urls
+}
+
+func (d *DefaultServiceInstance) GetEndPoints() []*Endpoint {
+ rawEndpoints := d.Metadata[constant.SERVICE_INSTANCE_ENDPOINTS]
+ if len(rawEndpoints) == 0 {
+ return nil
+ }
+ var endpoints []*Endpoint
+ err := json.Unmarshal([]byte(rawEndpoints), &endpoints)
+ if err != nil {
+ logger.Errorf("json umarshal rawEndpoints[%s] catch error:%s",
rawEndpoints, err.Error())
+ return nil
+ }
+ return endpoints
+}
+
+func (d *DefaultServiceInstance) Copy(endpoint *Endpoint) ServiceInstance {
Review comment:
pls add comment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]