using System; using System.Collections.Generic; using System.Linq; using System.Text; using Grpc.Core; using Grpc.Core.Interceptors; using Grpc.Extension.Client.Internal; namespace Grpc.Extension.Client.Interceptors { /// /// 客户端中间件的CallInvoker /// internal class InterceptorCallInvoker : CallInvoker { private CallInvoker _interceptorCallInvoker; public InterceptorCallInvoker(AutoChannelCallInvoker autoChannelCallInvoker, IEnumerable clientInterceptors) { _interceptorCallInvoker = autoChannelCallInvoker.Intercept(clientInterceptors.ToArray()); } public override TResponse BlockingUnaryCall(Method method, string host, CallOptions options, TRequest request) { return _interceptorCallInvoker.BlockingUnaryCall(method, host, options, request); } public override AsyncUnaryCall AsyncUnaryCall(Method method, string host, CallOptions options, TRequest request) { return _interceptorCallInvoker.AsyncUnaryCall(method, host, options, request); } public override AsyncServerStreamingCall AsyncServerStreamingCall(Method method, string host, CallOptions options, TRequest request) { return _interceptorCallInvoker.AsyncServerStreamingCall(method, host, options, request); } public override AsyncClientStreamingCall AsyncClientStreamingCall(Method method, string host, CallOptions options) { return _interceptorCallInvoker.AsyncClientStreamingCall(method, host, options); } public override AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, string host, CallOptions options) { return _interceptorCallInvoker.AsyncDuplexStreamingCall(method, host, options); } } }