private IPooledBuffer Serialize(IInvocationStart message, Nothing _) { using (var envelope = ClientToBrokerRequestEnvelope.Rent()) { var proto = InvocationStartRequest.Rent(); message.Target.Handle(_setInvocationTargetHandler, proto); envelope.InvocationStartRequest = proto; return(envelope.Serialize()); } }
private IPooledBuffer Serialize(IServiceDiscoveryRequest msg, Nothing _) { using (var envelope = ClientToBrokerRequestEnvelope.Rent()) { var proto = ServiceDiscoveryRequest.Rent(); proto.DiscoveryMode = ConvertToProto(msg.DiscoveryMode); proto.ConsumedService = ConvertToProto(msg.ConsumedService); envelope.ServiceDiscoveryRequest = proto; return(envelope.Serialize()); } }
private IPooledBuffer Serialize(IMethodDiscoveryRequest msg, Nothing _) { using (var envelope = ClientToBrokerRequestEnvelope.Rent()) { var proto = MethodDiscoveryRequest.Rent(); proto.DiscoveryMode = ConvertToProto(msg.DiscoveryMode); proto.InputMessageId = msg.InputMessageId.ConvertToProto(); proto.ConsumedMethod = ConvertToProto(msg.ConsumedMethod); proto.OutputMessageId = msg.OutputMessageId.ConvertToProto(); envelope.MethodDiscoveryRequest = proto; return(envelope.Serialize()); } }
public IClientToBrokerRequest DeserializeClientToBrokerRequest(IPooledBuffer message) { using (var envelope = ClientToBrokerRequestEnvelope.Rent()) { envelope.MergeFrom(message); switch (envelope.PayloadCase) { case ClientToBrokerRequestEnvelope.PayloadOneofCase.InvocationStartRequest: var invocationRequest = envelope.InvocationStartRequest; IInvocationTarget target; switch (invocationRequest.TargetCase) { case InvocationStartRequest.TargetOneofCase.ConsumedMethod: target = ConvertFromProtoStrict(invocationRequest.ConsumedMethod); break; case InvocationStartRequest.TargetOneofCase.ProvidedMethod: target = ConvertFromProtoStrict(invocationRequest.ProvidedMethod); break; default: throw new InvalidOperationException($"Unexpected target payload: {invocationRequest.TargetCase}"); } var contextLinkageOptions = ConvertFromProtoStrict(invocationRequest.ContextLinkageOptions); return(_messageFactory.CreateInvocationStartRequest(target, contextLinkageOptions)); case ClientToBrokerRequestEnvelope.PayloadOneofCase.ServiceDiscoveryRequest: return(ConvertFromProtoStrict(envelope.ServiceDiscoveryRequest)); case ClientToBrokerRequestEnvelope.PayloadOneofCase.MethodDiscoveryRequest: return(ConvertFromProtoStrict(envelope.MethodDiscoveryRequest)); default: throw new InvalidOperationException(); } } }