add needed files

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-09-12 23:24:32 +03:00
parent e265a6f83f
commit d797edb9a7
15 changed files with 2139 additions and 13 deletions

34
response.go Normal file
View File

@@ -0,0 +1,34 @@
package drpc
import (
"io"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/server"
)
var _ server.Response = &rpcResponse{}
type rpcResponse struct {
rw io.ReadWriter
header metadata.Metadata
codec codec.Codec
}
func (r *rpcResponse) Codec() codec.Codec {
return r.codec
}
func (r *rpcResponse) WriteHeader(hdr metadata.Metadata) {
for k, v := range hdr {
r.header[k] = v
}
}
func (r *rpcResponse) Write(b []byte) error {
return r.codec.Write(r.rw, &codec.Message{
Header: r.header,
Body: b,
}, nil)
}