Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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);
        }