Esempio n. 1
0
 public ClientCallInvoker(IEndpointStrategy strategy, string serviceName, int maxRetry = 0, IClientTracer tracer = null)
 {
     _strategy    = strategy;
     _serviceName = serviceName;
     _maxRetry    = maxRetry;
     _tracer      = tracer;
 }
        public ClientCallInvoker(IEndpointStrategy strategy, string serviceName, int maxRetry = 0, IClientTracer tracer = null, List <Interceptor> interceptors = null)
        {
            _strategy     = strategy;
            _serviceName  = serviceName;
            _maxRetry     = maxRetry;
            _tracer       = tracer;
            _interceptors = interceptors;

            if (_tracer != null)
            {
                _interceptors = _interceptors ?? new List <Interceptor>();
                _interceptors.Add(new ClientTracerInterceptor(_tracer));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取客户端
        /// </summary>
        /// <param name="configPath">配置文件路径</param>
        /// <param name="tracer">tracer拦截器</param>
        /// <param name="interceptors">自定义拦截器</param>
        /// <param name="callInvokers">自定义invoker获取策略</param>
        /// <returns></returns>
        public static T Get(string configPath = "", IClientTracer tracer = null, List <Interceptor> interceptors = null, Func <List <ServerCallInvoker>, ServerCallInvoker> callInvokers = null)
        {
            var options = new GrpcClientOptions()
            {
                Tracer     = tracer,
                ConfigPath = configPath,
            };

            if (interceptors?.Count > 0)
            {
                options.Interceptors.AddRange(interceptors);
            }
            return(Get(options, callInvokers));
        }
 public ClientTracerInterceptor(IClientTracer tracer)
 {
     _tracer = tracer;
 }
Esempio n. 5
0
        /// <summary>
        /// 获取客户端
        /// </summary>
        /// <param name="configPath"></param>
        /// <param name="tracer"></param>
        /// <returns></returns>
        public static T Get(string configPath = "", IClientTracer tracer = null)
        {
            var factory = new GrpcClientFactory <T>(tracer);

            return(_clientCache.GetOrAdd(typeof(T), key => factory.Get(configPath)));
        }
Esempio n. 6
0
        /// <summary>
        /// ClientIntercept注入
        /// </summary>
        /// <param name="callInvoker"></param>
        /// <param name="tracer"></param>
        /// <returns></returns>
        public static ServerCallInvoker ClientIntercept(this ServerCallInvoker callInvoker, IClientTracer tracer)
        {
            if (callInvoker == null)
            {
                return(callInvoker);
            }

            return(new InterceptedServerCallInvoker(callInvoker.Channel, tracer));
        }
Esempio n. 7
0
 public InterceptedServerCallInvoker(Channel channel, IClientTracer tracer)
     : base(channel)
 {
     _tracer = GrpcPreconditions.CheckNotNull(tracer);
 }
Esempio n. 8
0
 public GrpcClientFactory(IClientTracer tracer = null)
 {
     _tracer = tracer;
 }
Esempio n. 9
0
 public GrpcClientFactory(IOptions <GrpcClientOptions <T> > options = null, IClientTracer tracer = null)
 {
     _options = options?.Value;
     _tracer  = tracer;
 }
Esempio n. 10
0
 public GrpcClientFactory(IClientTracer tracer = null, List <Interceptor> interceptors = null)
 {
     _tracer       = tracer;
     _interceptors = interceptors;
 }
Esempio n. 11
0
 public GrpcClientFactory(IOptions <GrpcClientOptions <T> > options = null, IClientTracer tracer = null, IOptions <GrpcClientOptions> grpcOptions = null)
 {
     _options      = options?.Value;
     _tracer       = tracer;
     _interceptors = grpcOptions?.Value?.Interceptors;
 }
Esempio n. 12
0
 public InterceptedClientHandler(IClientTracer tracer, ClientInterceptorContext <TRequest, TResponse> context)
 {
     _tracer  = tracer;
     _context = context;
 }