private (string, string) InterceptCallContext(ServerCallContext context) { string method = context.Method; GrpcSettings.ParseHeader(context.RequestHeaders, out string sender, out string senderBuildId, out string traceId); if (!string.IsNullOrEmpty(senderBuildId) && senderBuildId != m_buildId) { string failureMessage = $"The receiver and sender build ids do not match. Receiver build id: {m_buildId}. Sender build id: {senderBuildId}."; Logger.Log.GrpcTrace(m_loggingContext, failureMessage); throw new RpcException( new Status( StatusCode.InvalidArgument, failureMessage)); } // example: [MW1AAP45DD9145A::89 -> SELF] 740adbf7-ae68-4a94-b6c1-578b4a2ecb67 Received: /BuildXL.Distribution.Grpc.Orchestrator/Notify. Logger.Log.GrpcTrace(m_loggingContext, string.Format(ReceivedLogFormat, sender, traceId, method)); return(sender, traceId); }
private (string Sender, string TraceId) InterceptCallContext(ServerCallContext context) { string method = context.Method; GrpcSettings.ParseHeader(context.RequestHeaders, out string sender, out var senderInvocationId, out string traceId, out string token); if (m_invocationId != senderInvocationId) { string failureMessage = $"The receiver and sender distributed invocation ids do not match. Receiver invocation id: {m_invocationId}. Sender invocation id: {senderInvocationId}."; Logger.Log.GrpcTrace(m_loggingContext, failureMessage); var trailers = new Metadata { { GrpcMetadata.InvocationIdMismatch, GrpcMetadata.True }, { GrpcMetadata.IsUnrecoverableError, IsUnrecoverableMismatch(senderInvocationId) ? GrpcMetadata.True : GrpcMetadata.False } }; throw new RpcException( new Status( StatusCode.InvalidArgument, failureMessage), trailers); } if (m_encryptionEnabled && token != m_token) { Logger.Log.GrpcAuthTrace(m_loggingContext, $"Authentication tokens do not match:\r\nReceived:{token}\r\nExpected:{m_token}"); var trailers = new Metadata { { GrpcMetadata.IsUnrecoverableError, GrpcMetadata.True } }; throw new RpcException(new Status(StatusCode.Unauthenticated, "Call could not be authenticated."), trailers); } // example: [MW1AAP45DD9145A::89 -> SELF] 740adbf7-ae68-4a94-b6c1-578b4a2ecb67 Received: /BuildXL.Distribution.Grpc.Orchestrator/Notify. Logger.Log.GrpcTrace(m_loggingContext, string.Format(ReceivedLogFormat, sender, traceId, method)); return(sender, traceId); }