1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Some nitpicking

This commit is contained in:
Asim 2015-12-02 01:38:56 +00:00
parent 7a870dfbb1
commit c5a08d3159
3 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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()
}

View File

@ -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 {