From 5c579a7a61475bde3ec9c1efe000d2a55e2a3cb2 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 29 Nov 2019 16:26:43 +0300 Subject: [PATCH] feat: allow different formats for messages streaming/unary Streaming response are never aggregated, so wrapping messages into `repeated` container looks like overhead as there will always be just a single entry in `repeated` container. Pass `streaming` flag down to `Backend` response building methods to support this flow. Test service was adjusted with the new proto layout. Signed-off-by: Andrey Smirnov --- proxy/DOC.md | 23 +++------ proxy/director.go | 12 +++-- proxy/handler_one2many.go | 16 +++--- proxy/handler_one2many_test.go | 85 ++++++++++++++++---------------- proxy/handler_one2one.go | 7 --- testservice/test.pb.go | 90 +++++++++++++++++----------------- testservice/test.proto | 32 ++++-------- 7 files changed, 120 insertions(+), 145 deletions(-) diff --git a/proxy/DOC.md b/proxy/DOC.md index cd9ab7f..bd52eaf 100644 --- a/proxy/DOC.md +++ b/proxy/DOC.md @@ -84,17 +84,19 @@ type Backend interface { // AppendInfo is called to enhance response from the backend with additional data. // + // Parameter streaming indicates if response is delivered in streaming mode or not. + // // Usecase might be appending backend endpoint (or name) to the protobuf serialized response, so that response is enhanced // with source information. This is particularly important for one to many calls, when it is required to identify // response from each of the backends participating in the proxying. // // If not additional proxying is required, simply returning the buffer without changes works fine. - AppendInfo(resp []byte) ([]byte, error) + AppendInfo(streaming bool, resp []byte) ([]byte, error) // BuildError is called to convert error from upstream into response field. // // BuildError is never called for one to one proxying, in that case all the errors are returned back to the caller - // as grpc errors. + // as grpc errors. Parameter streaming indicates if response is delivered in streaming mode or not. // // When proxying one to many, if one the requests fails or upstream returns an error, it is undesirable to fail the whole // request and discard responses from other backends. BuildError converts (marshals) error from backend into protobuf encoded @@ -102,7 +104,7 @@ type Backend interface { // N2 error responses so that N1 + N2 == N. // // If BuildError returns nil, error is returned as grpc error (failing whole request). - BuildError(err error) ([]byte, error) + BuildError(streaming bool, err error) ([]byte, error) } ``` @@ -148,15 +150,6 @@ func WithMethodNames(methodNames ...string) Option WithMethodNames configures list of method names to proxy for non-transparent handler. -#### func WithMode - -```go -func WithMode(mode Mode) Option -``` -WithMode sets proxying mode: One2One or One2Many. - -Default mode is One2One. - #### func WithStreamedDetector ```go @@ -258,14 +251,14 @@ for one to one proxying. #### func (*SingleBackend) AppendInfo ```go -func (sb *SingleBackend) AppendInfo(resp []byte) ([]byte, error) +func (sb *SingleBackend) AppendInfo(streaming bool, resp []byte) ([]byte, error) ``` AppendInfo is called to enhance response from the backend with additional data. #### func (*SingleBackend) BuildError ```go -func (sb *SingleBackend) BuildError(err error) ([]byte, error) +func (sb *SingleBackend) BuildError(streaming bool, err error) ([]byte, error) ``` BuildError is called to convert error from upstream into response field. @@ -285,7 +278,7 @@ func (sb *SingleBackend) String() string #### type StreamDirector ```go -type StreamDirector func(ctx context.Context, fullMethodName string) ([]Backend, error) +type StreamDirector func(ctx context.Context, fullMethodName string) (Mode, []Backend, error) ``` StreamDirector returns a list of Backend objects to forward the call to. diff --git a/proxy/director.go b/proxy/director.go index 655e30f..4d09b68 100644 --- a/proxy/director.go +++ b/proxy/director.go @@ -31,17 +31,19 @@ type Backend interface { // AppendInfo is called to enhance response from the backend with additional data. // + // Parameter streaming indicates if response is delivered in streaming mode or not. + // // Usecase might be appending backend endpoint (or name) to the protobuf serialized response, so that response is enhanced // with source information. This is particularly important for one to many calls, when it is required to identify // response from each of the backends participating in the proxying. // // If not additional proxying is required, simply returning the buffer without changes works fine. - AppendInfo(resp []byte) ([]byte, error) + AppendInfo(streaming bool, resp []byte) ([]byte, error) // BuildError is called to convert error from upstream into response field. // // BuildError is never called for one to one proxying, in that case all the errors are returned back to the caller - // as grpc errors. + // as grpc errors. Parameter streaming indicates if response is delivered in streaming mode or not. // // When proxying one to many, if one the requests fails or upstream returns an error, it is undesirable to fail the whole // request and discard responses from other backends. BuildError converts (marshals) error from backend into protobuf encoded @@ -49,7 +51,7 @@ type Backend interface { // N2 error responses so that N1 + N2 == N. // // If BuildError returns nil, error is returned as grpc error (failing whole request). - BuildError(err error) ([]byte, error) + BuildError(streaming bool, err error) ([]byte, error) } // SingleBackend implements a simple wrapper around get connection function of one to one proxying. @@ -74,12 +76,12 @@ func (sb *SingleBackend) GetConnection(ctx context.Context) (context.Context, *g } // AppendInfo is called to enhance response from the backend with additional data. -func (sb *SingleBackend) AppendInfo(resp []byte) ([]byte, error) { +func (sb *SingleBackend) AppendInfo(streaming bool, resp []byte) ([]byte, error) { return resp, nil } // BuildError is called to convert error from upstream into response field. -func (sb *SingleBackend) BuildError(err error) ([]byte, error) { +func (sb *SingleBackend) BuildError(streaming bool, err error) ([]byte, error) { return nil, nil } diff --git a/proxy/handler_one2many.go b/proxy/handler_one2many.go index 343f3ce..31b849f 100644 --- a/proxy/handler_one2many.go +++ b/proxy/handler_one2many.go @@ -58,8 +58,8 @@ func (s *handler) handlerOne2Many(fullMethodName string, serverStream grpc.Serve } // formatError tries to format error from upstream as message to the client -func (s *handler) formatError(src *backendConnection, backendErr error) ([]byte, error) { - payload, err := src.backend.BuildError(backendErr) +func (s *handler) formatError(streaming bool, src *backendConnection, backendErr error) ([]byte, error) { + payload, err := src.backend.BuildError(streaming, backendErr) if err != nil { return nil, fmt.Errorf("error building error for %s: %w", src.backend, err) } @@ -76,7 +76,7 @@ func (s *handler) formatError(src *backendConnection, backendErr error) ([]byte, // if sendError fails to deliver the error, error is returned // if sendError successfully delivers the error, nil is returned func (s *handler) sendError(src *backendConnection, dst grpc.ServerStream, backendErr error) error { - payload, err := s.formatError(src, backendErr) + payload, err := s.formatError(true, src, backendErr) if err != nil { return err } @@ -100,7 +100,7 @@ func (s *handler) forwardClientsToServerMultiUnary(sources []backendConnection, go func(src *backendConnection) { errCh <- func() error { if src.connError != nil { - payload, err := s.formatError(src, src.connError) + payload, err := s.formatError(false, src, src.connError) if err != nil { return err } @@ -120,7 +120,7 @@ func (s *handler) forwardClientsToServerMultiUnary(sources []backendConnection, return nil } - payload, err := s.formatError(src, err) + payload, err := s.formatError(false, src, err) if err != nil { return err } @@ -134,7 +134,7 @@ func (s *handler) forwardClientsToServerMultiUnary(sources []backendConnection, // This is the only place to do it nicely. md, err := src.clientStream.Header() if err != nil { - payload, err := s.formatError(src, err) + payload, err := s.formatError(false, src, err) if err != nil { return err } @@ -149,7 +149,7 @@ func (s *handler) forwardClientsToServerMultiUnary(sources []backendConnection, } var err error - f.payload, err = src.backend.AppendInfo(f.payload) + f.payload, err = src.backend.AppendInfo(false, f.payload) if err != nil { return fmt.Errorf("error appending info for %s: %w", src.backend, err) } @@ -224,7 +224,7 @@ func (s *handler) forwardClientsToServerMultiStreaming(sources []backendConnecti } var err error - f.payload, err = src.backend.AppendInfo(f.payload) + f.payload, err = src.backend.AppendInfo(true, f.payload) if err != nil { return fmt.Errorf("error appending info for %s: %w", src.backend, err) } diff --git a/proxy/handler_one2many_test.go b/proxy/handler_one2many_test.go index a54fbce..3374ef3 100644 --- a/proxy/handler_one2many_test.go +++ b/proxy/handler_one2many_test.go @@ -82,14 +82,10 @@ func (s *assertingMultiService) PingList(ping *pb.PingRequest, stream pb.MultiSe // Send user trailers and headers. stream.SendHeader(metadata.Pairs(serverHeaderMdKey, "I like turtles.")) //nolint: errcheck for i := 0; i < countListResponses; i++ { - stream.Send(&pb.MultiPingReply{ //nolint: errcheck - Response: []*pb.MultiPingResponse{ - { - Value: ping.Value, - Counter: int32(i), - Server: s.server, - }, - }, + stream.Send(&pb.MultiPingResponse{ //nolint: errcheck + Value: ping.Value, + Counter: int32(i), + Server: s.server, }) } stream.SetTrailer(metadata.Pairs(serverTrailerMdKey, "I like ending turtles.")) //nolint: errcheck @@ -107,14 +103,10 @@ func (s *assertingMultiService) PingStream(stream pb.MultiService_PingStreamServ require.NoError(s.t, err, "can't fail reading stream") return err } - pong := &pb.MultiPingReply{ - Response: []*pb.MultiPingResponse{ - { - Value: ping.Value, - Counter: counter, - Server: s.server, - }, - }, + pong := &pb.MultiPingResponse{ + Value: ping.Value, + Counter: counter, + Server: s.server, } if err := stream.Send(pong); err != nil { require.NoError(s.t, err, "can't fail sending back a pong") @@ -162,7 +154,17 @@ func (b *assertingBackend) GetConnection(ctx context.Context) (context.Context, return outCtx, b.conn, err } -func (b *assertingBackend) AppendInfo(resp []byte) ([]byte, error) { +func (b *assertingBackend) AppendInfo(streaming bool, resp []byte) ([]byte, error) { + payload, err := proto.Marshal(&pb.ResponseMetadataPrepender{ + Metadata: &pb.ResponseMetadata{ + Hostname: fmt.Sprintf("server%d", b.i), + }, + }) + + if streaming { + return append(resp, payload...), err + } + // decode protobuf embedded header typ, n1 := proto.DecodeVarint(resp) _, n2 := proto.DecodeVarint(resp[n1:]) // length @@ -171,12 +173,6 @@ func (b *assertingBackend) AppendInfo(resp []byte) ([]byte, error) { return nil, fmt.Errorf("unexpected message format: %d", typ) } - payload, err := proto.Marshal(&pb.ResponseMetadataPrepender{ - Metadata: &pb.ResponseMetadata{ - Hostname: fmt.Sprintf("server%d", b.i), - }, - }) - // cut off embedded message header resp = resp[n1+n2:] // build new embedded message header @@ -186,8 +182,8 @@ func (b *assertingBackend) AppendInfo(resp []byte) ([]byte, error) { return append(resp, payload...), err } -func (b *assertingBackend) BuildError(err error) ([]byte, error) { - return proto.Marshal(&pb.EmptyReply{ +func (b *assertingBackend) BuildError(streaming bool, err error) ([]byte, error) { + resp := &pb.EmptyReply{ Response: []*pb.EmptyResponse{ { Metadata: &pb.ResponseMetadata{ @@ -196,7 +192,13 @@ func (b *assertingBackend) BuildError(err error) ([]byte, error) { }, }, }, - }) + } + + if streaming { + return proto.Marshal(resp.Response[0]) + } + + return proto.Marshal(resp) } type ProxyOne2ManySuite struct { @@ -350,8 +352,7 @@ func (s *ProxyOne2ManySuite) TestPingStreamErrorPropagatesAppError() { resp, err := stream.Recv() s.Require().NoError(err) - s.Assert().Len(resp.Response, 1) - s.Assert().Equal("rpc error: code = FailedPrecondition desc = Userspace error.", resp.Response[0].Metadata.UpstreamError) + s.Assert().Equal("rpc error: code = FailedPrecondition desc = Userspace error.", resp.Metadata.UpstreamError) } require.NoError(s.T(), stream.CloseSend(), "no error on close send") @@ -373,8 +374,7 @@ func (s *ProxyOne2ManySuite) TestPingStreamConnError() { resp, err := stream.Recv() s.Require().NoError(err) - s.Assert().Len(resp.Response, 1) - s.Assert().Equal("rpc error: code = Unavailable desc = backend connection failed", resp.Response[0].Metadata.UpstreamError) + s.Assert().Equal("rpc error: code = Unavailable desc = backend connection failed", resp.Metadata.UpstreamError) _, err = stream.Recv() require.Equal(s.T(), io.EOF, err, "stream should close with io.EOF, meaning OK") @@ -407,11 +407,10 @@ func (s *ProxyOne2ManySuite) TestPingStream_FullDuplexWorks() { resp, err := stream.Recv() s.Require().NoError(err) - s.Assert().Len(resp.Response, 1) - s.Assert().EqualValues(i, resp.Response[0].Counter, "ping roundtrip must succeed with the correct id") - s.Assert().EqualValues(resp.Response[0].Metadata.Hostname, resp.Response[0].Server) + s.Assert().EqualValues(i, resp.Counter, "ping roundtrip must succeed with the correct id") + s.Assert().EqualValues(resp.Metadata.Hostname, resp.Server) - delete(expectedUpstreams, resp.Response[0].Metadata.Hostname) + delete(expectedUpstreams, resp.Metadata.Hostname) } s.Require().Empty(expectedUpstreams) @@ -464,24 +463,24 @@ func (s *ProxyOne2ManySuite) TestPingStream_FullDuplexConcurrent() { return err } - if len(resp.Response) != 1 { - return fmt.Errorf("single response expected: %d", len(resp.Response)) + if resp.Metadata == nil { + return fmt.Errorf("response metadata expected: %v", resp) } - if resp.Response[0].Metadata.Hostname != resp.Response[0].Server { - return fmt.Errorf("mismatch on host metadata: %v != %v", resp.Response[0].Metadata.Hostname, resp.Response[0].Server) + if resp.Metadata.Hostname != resp.Server { + return fmt.Errorf("mismatch on host metadata: %v != %v", resp.Metadata.Hostname, resp.Server) } - expectedCounter, ok := expectedUpstreams[resp.Response[0].Server] + expectedCounter, ok := expectedUpstreams[resp.Server] if !ok { - return fmt.Errorf("unexpected host: %v", resp.Response[0].Server) + return fmt.Errorf("unexpected host: %v", resp.Server) } - if expectedCounter != resp.Response[0].Counter { - return fmt.Errorf("unexpected counter value: %d != %d", expectedCounter, resp.Response[0].Counter) + if expectedCounter != resp.Counter { + return fmt.Errorf("unexpected counter value: %d != %d", expectedCounter, resp.Counter) } - expectedUpstreams[resp.Response[0].Server]++ + expectedUpstreams[resp.Server]++ } return nil diff --git a/proxy/handler_one2one.go b/proxy/handler_one2one.go index 28adadd..dff9d5a 100644 --- a/proxy/handler_one2one.go +++ b/proxy/handler_one2one.go @@ -64,13 +64,6 @@ func (s *handler) forwardClientToServer(src *backendConnection, dst grpc.ServerS break } - var err error - f.payload, err = src.backend.AppendInfo(f.payload) - if err != nil { - ret <- err - break - } - if i == 0 { // This is a bit of a hack, but client to server headers are only readable after first client msg is // received but must be written to server stream before the first msg is flushed. diff --git a/testservice/test.pb.go b/testservice/test.pb.go index 73664ba..f16a783 100644 --- a/testservice/test.pb.go +++ b/testservice/test.pb.go @@ -422,36 +422,36 @@ func init() { func init() { proto.RegisterFile("test.proto", fileDescriptor_c161fcfdc0c3ff1e) } var fileDescriptor_c161fcfdc0c3ff1e = []byte{ - // 459 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x93, 0xdd, 0x8e, 0xd2, 0x40, - 0x14, 0xc7, 0x2d, 0x08, 0x94, 0xc3, 0x97, 0x4e, 0x0c, 0xa9, 0xf8, 0x3d, 0xc6, 0x84, 0xab, 0x86, - 0xe0, 0x9d, 0x89, 0xdc, 0x28, 0x4a, 0xa2, 0x28, 0x16, 0xe5, 0xc2, 0x1b, 0x53, 0x61, 0xb2, 0xdb, - 0xa4, 0x5f, 0x3b, 0x9d, 0x92, 0xf0, 0x2a, 0xfb, 0x7a, 0xfb, 0x1c, 0x9b, 0xec, 0xcc, 0xb4, 0x65, - 0x81, 0x2e, 0xdb, 0x92, 0x5e, 0x9e, 0xff, 0x9c, 0xf3, 0x9b, 0x73, 0xe6, 0x7f, 0x06, 0x80, 0x91, - 0x80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, 0x4d, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x79, 0x7e, 0x81, 0xd6, 0x35, 0x06, 0x00, 0x00, + // 456 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x93, 0x5d, 0xcf, 0xd2, 0x30, + 0x14, 0xc7, 0x1d, 0x08, 0x8c, 0xc3, 0x9b, 0x36, 0x86, 0x4c, 0x7c, 0xaf, 0x31, 0xe1, 0x6a, 0x21, + 0x78, 0x67, 0x22, 0x37, 0x8a, 0x92, 0x28, 0xba, 0x0c, 0x34, 0xd1, 0x1b, 0x33, 0xa1, 0xd1, 0x25, + 0x7b, 0xb3, 0xeb, 0x48, 0xf8, 0x2a, 0x7e, 0x46, 0xbf, 0x82, 0x89, 0x6d, 0xb7, 0x21, 0xb0, 0x87, + 0x87, 0x92, 0x5d, 0x9e, 0x7f, 0xcf, 0xf9, 0xf5, 0x9c, 0xfe, 0x4f, 0x01, 0x18, 0x89, 0x99, 0x19, + 0xd1, 0x90, 0x85, 0xa8, 0xc7, 0x1c, 0x2f, 0x8c, 0x4d, 0xa1, 0x48, 0x01, 0x37, 0xa0, 0x36, 0xf5, + 0x23, 0xb6, 0xc5, 0x4f, 0xa1, 0x65, 0xb9, 0xc1, 0x0f, 0x9b, 0xfc, 0x4a, 0xf8, 0x21, 0xba, 0x03, + 0xb5, 0x8d, 0xe3, 0x25, 0xc4, 0xd0, 0x1e, 0x6b, 0xc3, 0xa6, 0x9d, 0x06, 0x78, 0x02, 0xed, 0x34, + 0x29, 0x8e, 0xc2, 0x20, 0x26, 0x22, 0xeb, 0xf3, 0x7e, 0x96, 0x0c, 0x90, 0x01, 0x8d, 0x55, 0x98, + 0x04, 0x8c, 0x50, 0xa3, 0xc2, 0xf5, 0x9a, 0x9d, 0x87, 0xf8, 0x13, 0xdc, 0xca, 0x6b, 0xe7, 0x84, + 0x39, 0x6b, 0x87, 0x39, 0x68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0xe6, 0x55, 0xd6, 0x8c, 0x58, 0xc7, 0x33, 0xac, + 0x13, 0xad, 0x72, 0xc8, 0x3b, 0xd0, 0x45, 0xe2, 0x7b, 0x97, 0xff, 0xbf, 0x72, 0xfd, 0x8c, 0x34, + 0xf4, 0x11, 0x40, 0x68, 0x0b, 0xf9, 0x4d, 0x4a, 0xe2, 0x86, 0xda, 0x48, 0x1b, 0xff, 0xa9, 0x42, + 0x5b, 0x6e, 0x4e, 0x6e, 0xc0, 0x1b, 0x15, 0x03, 0x1e, 0x5d, 0xb7, 0x7d, 0x7c, 0xc5, 0xf8, 0xd8, + 0x6f, 0x95, 0x2c, 0x50, 0x00, 0xcd, 0xd4, 0x4d, 0xb8, 0x77, 0x6a, 0x8d, 0x53, 0x92, 0xa5, 0xec, + 0x84, 0xc2, 0xef, 0x92, 0x76, 0x2c, 0x2f, 0xb0, 0x43, 0x89, 0x29, 0x3c, 0x41, 0x5f, 0xa0, 0xf7, + 0x9f, 0xaa, 0x32, 0xb7, 0x32, 0xfa, 0x7b, 0x5d, 0x1e, 0x3f, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, + 0x8f, 0xae, 0x5f, 0xeb, 0x3e, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -801,7 +801,7 @@ func (c *multiServiceClient) PingList(ctx context.Context, in *PingRequest, opts } type MultiService_PingListClient interface { - Recv() (*MultiPingReply, error) + Recv() (*MultiPingResponse, error) grpc.ClientStream } @@ -809,8 +809,8 @@ type multiServicePingListClient struct { grpc.ClientStream } -func (x *multiServicePingListClient) Recv() (*MultiPingReply, error) { - m := new(MultiPingReply) +func (x *multiServicePingListClient) Recv() (*MultiPingResponse, error) { + m := new(MultiPingResponse) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -828,7 +828,7 @@ func (c *multiServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOp type MultiService_PingStreamClient interface { Send(*PingRequest) error - Recv() (*MultiPingReply, error) + Recv() (*MultiPingResponse, error) grpc.ClientStream } @@ -840,8 +840,8 @@ func (x *multiServicePingStreamClient) Send(m *PingRequest) error { return x.ClientStream.SendMsg(m) } -func (x *multiServicePingStreamClient) Recv() (*MultiPingReply, error) { - m := new(MultiPingReply) +func (x *multiServicePingStreamClient) Recv() (*MultiPingResponse, error) { + m := new(MultiPingResponse) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -859,7 +859,7 @@ func (c *multiServiceClient) PingStreamError(ctx context.Context, opts ...grpc.C type MultiService_PingStreamErrorClient interface { Send(*PingRequest) error - Recv() (*MultiPingReply, error) + Recv() (*MultiPingResponse, error) grpc.ClientStream } @@ -871,8 +871,8 @@ func (x *multiServicePingStreamErrorClient) Send(m *PingRequest) error { return x.ClientStream.SendMsg(m) } -func (x *multiServicePingStreamErrorClient) Recv() (*MultiPingReply, error) { - m := new(MultiPingReply) +func (x *multiServicePingStreamErrorClient) Recv() (*MultiPingResponse, error) { + m := new(MultiPingResponse) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -979,7 +979,7 @@ func _MultiService_PingList_Handler(srv interface{}, stream grpc.ServerStream) e } type MultiService_PingListServer interface { - Send(*MultiPingReply) error + Send(*MultiPingResponse) error grpc.ServerStream } @@ -987,7 +987,7 @@ type multiServicePingListServer struct { grpc.ServerStream } -func (x *multiServicePingListServer) Send(m *MultiPingReply) error { +func (x *multiServicePingListServer) Send(m *MultiPingResponse) error { return x.ServerStream.SendMsg(m) } @@ -996,7 +996,7 @@ func _MultiService_PingStream_Handler(srv interface{}, stream grpc.ServerStream) } type MultiService_PingStreamServer interface { - Send(*MultiPingReply) error + Send(*MultiPingResponse) error Recv() (*PingRequest, error) grpc.ServerStream } @@ -1005,7 +1005,7 @@ type multiServicePingStreamServer struct { grpc.ServerStream } -func (x *multiServicePingStreamServer) Send(m *MultiPingReply) error { +func (x *multiServicePingStreamServer) Send(m *MultiPingResponse) error { return x.ServerStream.SendMsg(m) } @@ -1022,7 +1022,7 @@ func _MultiService_PingStreamError_Handler(srv interface{}, stream grpc.ServerSt } type MultiService_PingStreamErrorServer interface { - Send(*MultiPingReply) error + Send(*MultiPingResponse) error Recv() (*PingRequest, error) grpc.ServerStream } @@ -1031,7 +1031,7 @@ type multiServicePingStreamErrorServer struct { grpc.ServerStream } -func (x *multiServicePingStreamErrorServer) Send(m *MultiPingReply) error { +func (x *multiServicePingStreamErrorServer) Send(m *MultiPingResponse) error { return x.ServerStream.SendMsg(m) } diff --git a/testservice/test.proto b/testservice/test.proto index 2024416..9653a2c 100644 --- a/testservice/test.proto +++ b/testservice/test.proto @@ -2,12 +2,9 @@ syntax = "proto3"; package talos.testproto; -message Empty { -} +message Empty {} -message PingRequest { - string value = 1; -} +message PingRequest { string value = 1; } message PingResponse { string Value = 1; @@ -24,7 +21,6 @@ service TestService { rpc PingList(PingRequest) returns (stream PingResponse) {} rpc PingStream(stream PingRequest) returns (stream PingResponse) {} - } message ResponseMetadata { @@ -32,9 +28,7 @@ message ResponseMetadata { string upstream_error = 100; } -message ResponseMetadataPrepender { - ResponseMetadata metadata = 99; -} +message ResponseMetadataPrepender { ResponseMetadata metadata = 99; } message MultiPingResponse { ResponseMetadata metadata = 99; @@ -43,17 +37,11 @@ message MultiPingResponse { string server = 3; } -message MultiPingReply { - repeated MultiPingResponse response = 1; -} +message MultiPingReply { repeated MultiPingResponse response = 1; } -message EmptyReply { - repeated EmptyResponse response = 1; -} +message EmptyReply { repeated EmptyResponse response = 1; } -message EmptyResponse { - ResponseMetadata metadata = 99; -} +message EmptyResponse { ResponseMetadata metadata = 99; } service MultiService { rpc PingEmpty(Empty) returns (MultiPingReply) {} @@ -62,9 +50,9 @@ service MultiService { rpc PingError(PingRequest) returns (EmptyReply) {} - rpc PingList(PingRequest) returns (stream MultiPingReply) {} + rpc PingList(PingRequest) returns (stream MultiPingResponse) {} - rpc PingStream(stream PingRequest) returns (stream MultiPingReply) {} + rpc PingStream(stream PingRequest) returns (stream MultiPingResponse) {} - rpc PingStreamError(stream PingRequest) returns (stream MultiPingReply) {} -} \ No newline at end of file + rpc PingStreamError(stream PingRequest) returns (stream MultiPingResponse) {} +}