Example #1
0
        public override TResponse BlockingUnaryCall <TRequest, TResponse>(TRequest request, ClientInterceptorContext <TRequest, TResponse> context, BlockingUnaryCallContinuation <TRequest, TResponse> continuation)
        {
            var metadata = _processor.BeginRequest(context);

            try
            {
                var options = context.Options.WithHeaders(metadata);
                context = new ClientInterceptorContext <TRequest, TResponse>(context.Method, context.Host, options);
                var response = continuation(request, context);
                _processor.EndRequest();
                return(response);
            }
            catch (Exception ex)
            {
                _processor.DiagnosticUnhandledException(ex);
                throw ex;
            }
        }
        public T Call <T, TRequest, TResponse>(ClientInterceptorContext <TRequest, TResponse> context, Func <ClientInterceptorContext <TRequest, TResponse>, T> func)
            where TRequest : class
            where TResponse : class
        {
            var metadata = _processor.BeginRequest(context);

            try
            {
                var options    = context.Options.WithHeaders(metadata);
                var newContext = new ClientInterceptorContext <TRequest, TResponse>(context.Method, context.Host, options);
                var response   = func(newContext);
                _processor.EndRequest();
                return(response);
            }
            catch (Exception ex)
            {
                _processor.DiagnosticUnhandledException(ex);
                throw;
            }
        }