public List <(string serviceId, string target)> FindServiceEndpoints(bool filterBlack = true) { if (_client == null) { throw new ArgumentNullException("consul client"); } var targets = new List <(string, string)>(); try { var r = _client.Health.Service(Options.ServiceName, "", true).Result; if (r.StatusCode != HttpStatusCode.OK) { throw new ApplicationException($"failed to query consul server"); } targets = r.Response .Select(x => (x.Service.ID, $"{x.Service.Address}:{x.Service.Port}")) .Where(target => !ServiceBlackPolicy.In(Options.ServiceName, target.Item2) || !filterBlack) .ToList(); } catch { } return(targets); }
public List <(string serviceId, string target)> FindServiceEndpoints(bool filterBlack = true) { if ((_ipEndPoints?.Count ?? 0) <= 0) { throw new ArgumentOutOfRangeException("endpoint not provide"); } var targets = _ipEndPoints.Select(x => ("", $"{x.Item1}:{x.Item2}")) .Where(target => !ServiceBlackPolicy.In(Options.ServiceName, target.Item2) || !filterBlack) .ToList(); return(targets); }