rename codec interface
This commit is contained in:
parent
9544058af3
commit
e8b431c5ff
@ -47,8 +47,8 @@ type readWriteCloser struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type clientCodec interface {
|
type clientCodec interface {
|
||||||
WriteRequest(*request, interface{}) error
|
Write(*request, interface{}) error
|
||||||
ReadResponse(*response, interface{}) error
|
Read(*response, interface{}) error
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ func newRpcCodec(req *transport.Message, client transport.Client, c codec.NewCod
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *rpcCodec) WriteRequest(req *request, body interface{}) error {
|
func (c *rpcCodec) Write(req *request, body interface{}) error {
|
||||||
c.buf.wbuf.Reset()
|
c.buf.wbuf.Reset()
|
||||||
|
|
||||||
m := &codec.Message{
|
m := &codec.Message{
|
||||||
@ -133,7 +133,7 @@ func (c *rpcCodec) WriteRequest(req *request, body interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *rpcCodec) ReadResponse(r *response, b interface{}) error {
|
func (c *rpcCodec) Read(r *response, b interface{}) error {
|
||||||
var m transport.Message
|
var m transport.Message
|
||||||
if err := c.client.Recv(&m); err != nil {
|
if err := c.client.Recv(&m); err != nil {
|
||||||
return errors.InternalServerError("go.micro.client.transport", err.Error())
|
return errors.InternalServerError("go.micro.client.transport", err.Error())
|
||||||
|
@ -51,7 +51,7 @@ func (r *rpcStream) Send(msg interface{}) error {
|
|||||||
ServiceMethod: r.request.Method(),
|
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
|
r.err = err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ func (r *rpcStream) Recv(msg interface{}) error {
|
|||||||
|
|
||||||
var resp response
|
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() {
|
if err == io.EOF && !r.isClosed() {
|
||||||
r.err = io.ErrUnexpectedEOF
|
r.err = io.ErrUnexpectedEOF
|
||||||
return io.ErrUnexpectedEOF
|
return io.ErrUnexpectedEOF
|
||||||
@ -81,7 +81,7 @@ func (r *rpcStream) Recv(msg interface{}) error {
|
|||||||
switch {
|
switch {
|
||||||
case len(resp.Error) > 0:
|
case len(resp.Error) > 0:
|
||||||
// We've got an error response. Give this to the request;
|
// 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.
|
// error if there is one.
|
||||||
if resp.Error != lastStreamResponseError {
|
if resp.Error != lastStreamResponseError {
|
||||||
r.err = serverError(resp.Error)
|
r.err = serverError(resp.Error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user