Some nitpicking
This commit is contained in:
parent
7a870dfbb1
commit
c5a08d3159
@ -16,8 +16,11 @@ type MessageType int
|
|||||||
// Takes in a connection/buffer and returns a new Codec
|
// Takes in a connection/buffer and returns a new Codec
|
||||||
type NewCodec func(io.ReadWriteCloser) Codec
|
type NewCodec func(io.ReadWriteCloser) Codec
|
||||||
|
|
||||||
// Codec encodes/decodes various types of
|
// Codec encodes/decodes various types of messages used within go-micro.
|
||||||
// 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 {
|
type Codec interface {
|
||||||
ReadHeader(*Message, MessageType) error
|
ReadHeader(*Message, MessageType) error
|
||||||
ReadBody(interface{}) error
|
ReadBody(interface{}) error
|
||||||
|
@ -71,7 +71,7 @@ func (s *rpcServer) accept(sock transport.Socket) {
|
|||||||
|
|
||||||
ctx := c.WithMetadata(context.Background(), hdr)
|
ctx := c.WithMetadata(context.Background(), hdr)
|
||||||
// TODO: needs better error handling
|
// 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)
|
log.Errorf("Unexpected error serving request, closing socket: %v", err)
|
||||||
sock.Close()
|
sock.Close()
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ func (m *methodType) prepareContext(ctx context.Context) reflect.Value {
|
|||||||
return reflect.Zero(m.ContextType)
|
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)
|
sending := new(sync.Mutex)
|
||||||
service, mtype, req, argv, replyv, keepReading, err := server.readRequest(codec)
|
service, mtype, req, argv, replyv, keepReading, err := server.readRequest(codec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user