示例#1
0
        public Response Process(Request req)
        {
            s_diagnosticListener.HostingRequest(req);
            var response = req.CreateResponse();

            try
            {
                if (!"tars_ping".Equals(req.FuncName, StringComparison.OrdinalIgnoreCase))
                {
                    serverInvoker.Invoke(req, response);
                }
            }
            catch (TarsException ex)
            {
                response.ResultStatusCode = ex.RpcStatusCode;
                response.ResultDesc       = ex.Message;
                s_diagnosticListener.HostingException(req, response, ex);
            }
            catch (Exception ex)
            {
                response.ResultStatusCode = RpcStatusCode.ServerUnknownErr;
                response.ResultDesc       = ex.Message;
                s_diagnosticListener.HostingException(req, response, ex);
            }
            finally
            {
                s_diagnosticListener.HostingResponse(req, response);
            }

            return(response);
        }
示例#2
0
        public void WhenCanHostingResponseShouldSameRequest()
        {
            var listener = new DiagnosticListener(D.DiagnosticListenerName);
            var sut      = new TestDiagnostic();

            listener.SubscribeWithAdapter(sut);
            var result   = new Request();
            var response = new Response();

            listener.HostingResponse(result, response);
            Assert.Same(result, sut.Request);
            Assert.Same(response, sut.Response);
        }