/// <summary> /// 解析Consul配置 /// </summary> /// <param name="serviceElement"></param> /// <returns></returns> private static IEndpointStrategy ResolveStickyConfiguration(Client.GrpcServiceElement serviceElement, string address) { var serviceName = serviceElement.Name; var discovery = serviceElement.Discovery; // consul var stickyEndpointDiscovery = new StickyEndpointDiscovery(serviceName, address); StickyEndpointStrategy.Instance.AddServiceDiscovery(stickyEndpointDiscovery); return(StickyEndpointStrategy.Instance); }
/// <summary> /// 解析Endpoint配置 /// </summary> /// <param name="serviceElement"></param> /// <returns></returns> private static IEndpointStrategy ResolveEndpointConfiguration(Client.GrpcServiceElement serviceElement) { var serviceName = serviceElement.Name; var discovery = serviceElement.Discovery; List <Tuple <string, int> > ipEndPoints = null; #if NET45 || NET46 || NET47 ipEndPoints = discovery.EndPoints.ToList(); #else ipEndPoints = discovery.EndPoints.Select(oo => Tuple.Create(oo.Host, oo.Port)).ToList(); #endif var iPEndpointDiscovery = new IPEndpointDiscovery(serviceName, ipEndPoints); IPEndpointStrategy.Instance.AddServiceDiscovery(iPEndpointDiscovery); return(IPEndpointStrategy.Instance); }