wqyenjoy commented on code in PR #2937: URL: https://github.com/apache/dubbo-go/pull/2937#discussion_r2190003082
########## registry/nacos/service_discovery.go: ########## @@ -406,3 +415,27 @@ func newNacosServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error } return newInstance, nil } + +// convertInstances converts nacos model.Instance to registry.ServiceInstance +// This method is used for testing weight conversion +func (n *nacosServiceDiscovery) convertInstances(instances []model.Instance) []registry.ServiceInstance { + res := make([]registry.ServiceInstance, 0, len(instances)) + for _, ins := range instances { + metadata := ins.Metadata + id := metadata[idKey] + delete(metadata, idKey) + + res = append(res, ®istry.DefaultServiceInstance{ + ID: id, + ServiceName: "test-service", // service name for test + Host: ins.Ip, + Port: int(ins.Port), + Weight: int64(math.Round(ins.Weight)), // Ensure weight is correctly passed (for test) + Enable: ins.Enable, + Healthy: ins.Healthy, + Metadata: metadata, + GroupName: n.group, + }) + } + return res +} Review Comment: antther good idea -- 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. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org