diff --git a/proxy/codec.go b/proxy/codec.go index 0ef2424..205f909 100644 --- a/proxy/codec.go +++ b/proxy/codec.go @@ -32,17 +32,21 @@ type rawCodec struct { parentCodec grpc.Codec //nolint: staticcheck } -type frame struct { +type Frame struct { payload []byte } +func (f *Frame) Size() int { + return len(f.payload) +} + // NewFrame constructs a frame for raw codec. func NewFrame(payload []byte) interface{} { - return &frame{payload: payload} + return &Frame{payload: payload} } func (c *rawCodec) Marshal(v interface{}) ([]byte, error) { - out, ok := v.(*frame) + out, ok := v.(*Frame) if !ok { return c.parentCodec.Marshal(v) } @@ -51,7 +55,7 @@ func (c *rawCodec) Marshal(v interface{}) ([]byte, error) { } func (c *rawCodec) Unmarshal(data []byte, v interface{}) error { - dst, ok := v.(*frame) + dst, ok := v.(*Frame) if !ok { return c.parentCodec.Unmarshal(data, v) } diff --git a/proxy/handler_one2many.go b/proxy/handler_one2many.go index b2beb6c..203fb81 100644 --- a/proxy/handler_one2many.go +++ b/proxy/handler_one2many.go @@ -123,7 +123,7 @@ func (s *handler) forwardClientsToServerMultiUnary(sources []backendConnection, return nil } - f := &frame{} + f := &Frame{} for j := 0; ; j++ { if err := src.clientStream.RecvMsg(f); err != nil { @@ -225,7 +225,7 @@ func (s *handler) forwardClientsToServerMultiStreaming(sources []backendConnecti return s.sendError(src, dst, src.connError) } - f := &frame{} + f := &Frame{} for j := 0; ; j++ { if err := src.clientStream.RecvMsg(f); err != nil {