示例#1
0
        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="serviceName"></param>
        /// <returns></returns>
        public ServerCallInvoker Get(string serviceName)
        {
            if (_invokers.TryGetValue(serviceName, out List <ServerCallInvoker> callInvokers) &&
                callInvokers.Count > 0)
            {
                return(ServicePollingPlicy.Random(callInvokers));
            }

            lock (_lock)
            {
                if (_invokers.TryGetValue(serviceName, out callInvokers) &&
                    callInvokers.Count > 0)
                {
                    return(ServicePollingPlicy.Random(callInvokers));
                }

                callInvokers = SetCallInvokers(serviceName);
                if ((callInvokers?.Count ?? 0) <= 0 && ServiceBlackPlicy.Exist(serviceName))
                {
                    callInvokers = SetCallInvokers(serviceName, false);
                }

                return(ServicePollingPlicy.Random(callInvokers));
            }
        }
示例#2
0
        /// <summary>
        /// 获取callinvoker
        /// </summary>
        /// <param name="serviceName"></param>
        /// <returns></returns>
        public ServerCallInvoker Get(string serviceName)
        {
            if (_invokers.TryGetValue(serviceName, out List <ServerCallInvoker> callInvokers) &&
                callInvokers?.Count > 0)
            {
                return(ServicePollingPlicy.Random(callInvokers));
            }

            lock (_lock)
            {
                if (_invokers.TryGetValue(serviceName, out callInvokers) &&
                    callInvokers?.Count > 0)
                {
                    return(ServicePollingPlicy.Random(callInvokers));
                }

                callInvokers = SetCallInvokers(serviceName);
                return(ServicePollingPlicy.Random(callInvokers));
            }
        }