public async Task <IList <Instance> > GetAllInstances(string serviceName, string groupName, IList <string> clusters, bool subscribe) { ServiceInfo serviceInfo = null; if (subscribe) { serviceInfo = await _hostReactor.GetServiceInfo(GetGroupedName(serviceName, groupName), string.Join(",", clusters)); } else { serviceInfo = await _hostReactor.GetServiceInfoDirectlyFromServer(GetGroupedName(serviceName, groupName), string.Join(",", clusters)); } if (serviceInfo == null || serviceInfo.Hosts.Count <= 0) { return(new List <Instance>()); } return(serviceInfo.Hosts); }
public async Task GetServiceInfoTest() { var orderInfo = await _hostReactor.GetServiceInfo(_orderServiceInfo.Name, _orderServiceInfo.Clusters); Assert.NotNull(orderInfo); Assert.Equal(orderInfo.Name, _orderServiceInfo.Name); Assert.Equal(orderInfo.GroupName, _orderServiceInfo.GroupName); Assert.Equal(orderInfo.Clusters, _orderServiceInfo.Clusters); Assert.Equal(orderInfo.Hosts.Count, _orderServiceInfo.Hosts.Count); Assert.Equal(orderInfo.Hosts.First().InstanceId, _orderServiceInfo.Hosts.First().InstanceId); Assert.Equal(orderInfo.Hosts.First().Ip, _orderServiceInfo.Hosts.First().Ip); Assert.Equal(orderInfo.Hosts.First().Metadata.Count, _orderServiceInfo.Hosts.First().Metadata.Count); Assert.Equal(orderInfo.Hosts.First().Port, _orderServiceInfo.Hosts.First().Port); Assert.Equal(orderInfo.Hosts.First().ServiceName, _orderServiceInfo.Hosts.First().ServiceName); Assert.Equal(orderInfo.LastRefTime, _orderServiceInfo.LastRefTime); orderInfo = await _hostReactor.GetServiceInfo(_orderServiceInfo.Name, _orderServiceInfo.Clusters); Assert.NotNull(orderInfo); }