private void Reset(GrpcClientOptions opt)
        {
#if NETCOREAPP3_1
            var host = new Uri(opt.Url !).Host;
            var port = new Uri(opt.Url !).Port;
            _client = new Client(GrpcChannel.ForAddress(opt.Url !, opt.ChannelOptions !), host, port, opt.ToString());
#else
            if (string.IsNullOrEmpty(opt.PublicKey))
            {
                _client = new Client(new Channel(opt.Host, opt.Port, ChannelCredentials.Insecure), opt.Host !, opt.Port, opt.ToString());
            }
            else
            {
                Channel channel;
                var     ssl = new SslCredentials(opt.PublicKey);
                if (string.IsNullOrEmpty(opt.SslTargetName))
                {
                    channel = new Channel(opt.Host, opt.Port, ssl);
                }
                else
                {
                    var options = new List <ChannelOption>();
                    options.Add(new ChannelOption(ChannelOptions.SslTargetNameOverride, opt.SslTargetName));
                    channel = new Channel(opt.Host, opt.Port, ssl, options);
                }
                _client = new Client(channel, opt.Host !, opt.Port, opt.ToString());
            }
#endif
            _client.Connect();
        }
Exemple #2
0
        public static ClientProxy <TService> CreateClientProxy <TService>(GrpcClientOptions options, int timeoutInterval = 1200000,
                                                                          int hearbeatInterval = 10000) where TService : class
        {
            var opt = new GrpcClientConnectionFactoryOptions(options);

            return(CreateClientProxy <TService>(opt, timeoutInterval, hearbeatInterval));
        }
Exemple #3
0
 public GrpcClientConnectionFactoryOptions(GrpcClientOptions options)
 {
     Factory = new GrpcClientConnectionFactory(new SimpleOptions <GrpcClientOptions>(options), NullLoggerFactory.Instance);
 }