コード例 #1
0
        public INiftyClientChannel BorrowChannel(ChannelKey key)
        {
            var connector = new FramedClientConnector(key.IpEndPoint.Address.ToString(), key.IpEndPoint.Port,
                                                      _options.LoggerFactory);

            var channel = _thriftClientManager.CreateChannelAsync(connector, TimeSpan.FromMilliseconds(key.ConnectionTimeout),
                                                                  TimeSpan.FromMilliseconds(key.ReceiveTimeout), TimeSpan.FromMilliseconds(key.ReadTimeout),
                                                                  TimeSpan.FromMilliseconds(key.WriteTimeout), _options.MaxFrameSize, key.SslConfig, _options.SocketProxy);

            return(channel.GetAwaiter().GetResult());
        }
コード例 #2
0
        public NiftyClientChannelFactory(ThriftClientManager thriftClientManager, ThriftyClientOptions options)
        {
            Guard.ArgumentNotNull(options, nameof(options));
            Guard.ArgumentNotNull(thriftClientManager, nameof(thriftClientManager));

            _createChannel = key =>
            {
                var connector = new FramedClientConnector(key.IpEndPoint.Address.ToString(), key.IpEndPoint.Port,
                                                          _options.LoggerFactory);

                var channel = thriftClientManager.CreateChannelAsync(connector, TimeSpan.FromMilliseconds(key.ConnectionTimeout),
                                                                     TimeSpan.FromMilliseconds(key.ReceiveTimeout), TimeSpan.FromMilliseconds(key.ReadTimeout),
                                                                     TimeSpan.FromMilliseconds(key.WriteTimeout), _options.MaxFrameSize, key.SslConfig, _options.SocketProxy);

                return(channel.GetAwaiter().GetResult());
            };
            _options = options;
        }