Esempio n. 1
0
        private static IGrpcCall <TRequest, TResponse> CreateRootGrpcCall <TRequest, TResponse>(
            GrpcChannel channel,
            Method <TRequest, TResponse> method,
            CallOptions options)
            where TRequest : class
            where TResponse : class
        {
            var methodInfo    = channel.GetCachedGrpcMethodInfo(method);
            var retryPolicy   = methodInfo.MethodConfig?.RetryPolicy;
            var hedgingPolicy = methodInfo.MethodConfig?.HedgingPolicy;

            if (retryPolicy != null)
            {
                return(new RetryCall <TRequest, TResponse>(retryPolicy, channel, method, options));
            }
            else if (hedgingPolicy != null)
            {
                return(new HedgingCall <TRequest, TResponse>(hedgingPolicy, channel, method, options));
            }
            else
            {
                // No retry/hedge policy configured. Fast path!
                return(CreateGrpcCall <TRequest, TResponse>(channel, method, options, attempt: 1));
            }
        }
Esempio n. 2
0
        public static GrpcCall <TRequest, TResponse> CreateGrpcCall <TRequest, TResponse>(
            GrpcChannel channel,
            Method <TRequest, TResponse> method,
            CallOptions options,
            int attempt)
            where TRequest : class
            where TResponse : class
        {
            if (channel.Disposed)
            {
                throw new ObjectDisposedException(nameof(GrpcChannel));
            }

            var methodInfo = channel.GetCachedGrpcMethodInfo(method);
            var call       = new GrpcCall <TRequest, TResponse>(method, methodInfo, options, channel, attempt);

            return(call);
        }