From c5a08d3159172abdcc503658d478b378543335ed Mon Sep 17 00:00:00 2001 From: Asim Date: Wed, 2 Dec 2015 01:38:56 +0000 Subject: [PATCH] Some nitpicking --- codec/codec.go | 7 +++++-- server/rpc_server.go | 2 +- server/rpcplus_server.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/codec/codec.go b/codec/codec.go index 4fb9b5ec..4e9566d5 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -16,8 +16,11 @@ type MessageType int // Takes in a connection/buffer and returns a new Codec type NewCodec func(io.ReadWriteCloser) Codec -// Codec encodes/decodes various types of -// messages used within go-micro +// Codec encodes/decodes various types of messages used within go-micro. +// ReadHeader and ReadBody are called in pairs to read requests/responses +// from the connection. Close is called when finished with the +// connection. ReadBody may be called with a nil argument to force the +// body to be read and discarded. type Codec interface { ReadHeader(*Message, MessageType) error ReadBody(interface{}) error diff --git a/server/rpc_server.go b/server/rpc_server.go index d28bb658..391f8b0e 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -71,7 +71,7 @@ func (s *rpcServer) accept(sock transport.Socket) { ctx := c.WithMetadata(context.Background(), hdr) // TODO: needs better error handling - if err := s.rpc.ServeRequestWithContext(ctx, codec); err != nil { + if err := s.rpc.serveRequest(ctx, codec); err != nil { log.Errorf("Unexpected error serving request, closing socket: %v", err) sock.Close() } diff --git a/server/rpcplus_server.go b/server/rpcplus_server.go index 7c1e008a..e73c2ac7 100644 --- a/server/rpcplus_server.go +++ b/server/rpcplus_server.go @@ -337,7 +337,7 @@ func (m *methodType) prepareContext(ctx context.Context) reflect.Value { return reflect.Zero(m.ContextType) } -func (server *server) ServeRequestWithContext(ctx context.Context, codec serverCodec) error { +func (server *server) serveRequest(ctx context.Context, codec serverCodec) error { sending := new(sync.Mutex) service, mtype, req, argv, replyv, keepReading, err := server.readRequest(codec) if err != nil {