rename codec interface

This commit is contained in:
Asim Aslam 2019-01-07 18:17:13 +00:00
parent 9544058af3
commit e8b431c5ff
2 changed files with 7 additions and 7 deletions

View File

@ -47,8 +47,8 @@ type readWriteCloser struct {
}
type clientCodec interface {
WriteRequest(*request, interface{}) error
ReadResponse(*response, interface{}) error
Write(*request, interface{}) error
Read(*response, interface{}) error
Close() error
}
@ -106,7 +106,7 @@ func newRpcCodec(req *transport.Message, client transport.Client, c codec.NewCod
return r
}
func (c *rpcCodec) WriteRequest(req *request, body interface{}) error {
func (c *rpcCodec) Write(req *request, body interface{}) error {
c.buf.wbuf.Reset()
m := &codec.Message{
@ -133,7 +133,7 @@ func (c *rpcCodec) WriteRequest(req *request, body interface{}) error {
return nil
}
func (c *rpcCodec) ReadResponse(r *response, b interface{}) error {
func (c *rpcCodec) Read(r *response, b interface{}) error {
var m transport.Message
if err := c.client.Recv(&m); err != nil {
return errors.InternalServerError("go.micro.client.transport", err.Error())

View File

@ -51,7 +51,7 @@ func (r *rpcStream) Send(msg interface{}) error {
ServiceMethod: r.request.Method(),
}
if err := r.codec.WriteRequest(&req, msg); err != nil {
if err := r.codec.Write(&req, msg); err != nil {
r.err = err
return err
}
@ -69,7 +69,7 @@ func (r *rpcStream) Recv(msg interface{}) error {
var resp response
if err := r.codec.ReadResponse(&resp, msg); err != nil {
if err := r.codec.Read(&resp, msg); err != nil {
if err == io.EOF && !r.isClosed() {
r.err = io.ErrUnexpectedEOF
return io.ErrUnexpectedEOF
@ -81,7 +81,7 @@ func (r *rpcStream) Recv(msg interface{}) error {
switch {
case len(resp.Error) > 0:
// We've got an error response. Give this to the request;
// any subsequent requests will get the ReadResponseBody
// any subsequent requests will get the ReadBody
// error if there is one.
if resp.Error != lastStreamResponseError {
r.err = serverError(resp.Error)