Example #1
0
 /// <summary>
 /// rpc消费者
 /// </summary>
 /// <param name="uri"></param>
 /// <param name="links"></param>
 /// <param name="retry"></param>
 /// <param name="timeOut"></param>
 public ServiceConsumer(Uri uri, int links = 4, int retry = 5, int timeOut = 10 * 1000)
 {
     _retry = retry;
     _consumerMultiplexer = ConsumerMultiplexer.Create(uri, links, timeOut);
     _consumerMultiplexer.OnDisconnected += _consumerMultiplexer_OnDisconnected;
     _consumerMultiplexer.OnError        += _consumerMultiplexer_OnError;
 }
Example #2
0
        /// <summary>
        /// 创建多路复用
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="links"></param>
        /// <param name="timeOut"></param>
        /// <param name="retry"></param>
        /// <returns></returns>
        public static ConsumerMultiplexer Create(Uri uri, int links = 4, int timeOut = 3 * 1000, int retry = 5)
        {
            var cm = new ConsumerMultiplexer(uri, links, timeOut, retry);

            cm.IsConnected = true;
            return(cm);
        }
Example #3
0
        /// <summary>
        /// 创建多路复用
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="links"></param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static ConsumerMultiplexer Create(Uri uri, int links = 4, int timeOut = 10 * 1000)
        {
            if (!_hashMap.Exits(uri.ToString()))
            {
                for (int i = 0; i < links; i++)
                {
                    var rClient = new RClient(uri);
                    rClient.Connect();
                    rClient.KeepAlive();
                    _hashMap.Set(uri.ToString(), i, rClient);
                }
            }
            var cm = new ConsumerMultiplexer(uri, links, timeOut);

            cm.IsConnected = true;
            return(cm);
        }
Example #4
0
 /// <summary>
 /// rpc消费者
 /// </summary>
 /// <param name="uri"></param>
 /// <param name="retry"></param>
 public ServiceConsumer(Uri uri, int retry = 5)
 {
     _retry = retry;
     _consumerMultiplexer          = ConsumerMultiplexer.Create(uri);
     _consumerMultiplexer.OnError += _consumerMultiplexer_OnError;
 }