codec rewrite

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-11-26 01:17:21 +03:00
parent 5098a36a6b
commit 36040a5765
9 changed files with 306 additions and 318 deletions

View File

@@ -1,16 +1,23 @@
package grpc
import (
"io"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/metadata"
)
type rpcResponse struct {
header metadata.Metadata
codec codec.Codec
rw io.ReadWriter
header metadata.Metadata
codec codec.Codec
endpoint string
service string
method string
target string
}
func (r *rpcResponse) Codec() codec.Writer {
func (r *rpcResponse) Codec() codec.Codec {
return r.codec
}
@@ -21,7 +28,7 @@ func (r *rpcResponse) WriteHeader(hdr metadata.Metadata) {
}
func (r *rpcResponse) Write(b []byte) error {
return r.codec.Write(&codec.Message{
return r.codec.Write(r.rw, &codec.Message{
Header: r.header,
Body: b,
}, nil)