private GcpCallInvoker GetCallInvoker(string endpoint, GrpcChannelOptions options, ChannelCredentials credentials)
        {
            var effectiveOptions = s_defaultOptions.MergedWith(options ?? GrpcChannelOptions.Empty);
            var key = new Key(endpoint, effectiveOptions);

            lock (_lock)
            {
                if (!_callInvokers.TryGetValue(key, out GcpCallInvoker callInvoker))
                {
                    callInvoker        = new GcpCallInvoker(endpoint, credentials, GrpcCoreAdapter.Instance.ConvertOptions(effectiveOptions));
                    _callInvokers[key] = callInvoker;
                }
                return(callInvoker);
            }
        }
        private GcpCallInvoker GetCallInvoker(string endpoint, ChannelCredentials credentials, GrpcChannelOptions options, ApiConfig apiConfig, GrpcAdapter adapter)
        {
            var effectiveOptions = s_defaultOptions.MergedWith(options ?? GrpcChannelOptions.Empty);

            apiConfig = apiConfig.Clone();
            var key = new Key(endpoint, effectiveOptions, apiConfig, adapter);

            lock (_lock)
            {
                if (!_callInvokers.TryGetValue(key, out GcpCallInvoker callInvoker))
                {
                    callInvoker        = new GcpCallInvoker(_serviceMetadata, endpoint, credentials, effectiveOptions, apiConfig, adapter);
                    _callInvokers[key] = callInvoker;
                }
                return(callInvoker);
            }
        }
示例#3
0
        private GcpCallInvoker GetCallInvoker(ServiceEndpoint endpoint, IEnumerable <ChannelOption> options, ChannelCredentials credentials)
        {
            var optionsList = options?.ToList() ?? new List <ChannelOption>();

            // "After a duration of this time the client/server pings its peer to see if the
            // transport is still alive. Int valued, milliseconds."
            // Required for any channel using a streaming RPC, to ensure an idle stream doesn't
            // allow the TCP connection to be silently dropped by any intermediary network devices.
            // 60 second keepalive time is reasonable. This will only add minimal network traffic,
            // and only if the channel is idle for more than 60 seconds.
            optionsList.Add(new ChannelOption("grpc.keepalive_time_ms", 60_000));

            var key = new Key(endpoint, optionsList);

            lock (_lock)
            {
                if (!_callInvokers.TryGetValue(key, out GcpCallInvoker callInvoker))
                {
                    callInvoker        = new GcpCallInvoker(endpoint.ToString(), credentials, optionsList);
                    _callInvokers[key] = callInvoker;
                }
                return(callInvoker);
            }
        }