func (conn *Conn) loop() error {
	defer conn.cancelContext()
	for {
		var hdr Header
		err := conn.codec.ReadHeader(&hdr)
		switch {
		case errors.Cause(err) == io.EOF:
			// handle sentinel error specially
			return err
		case err != nil:
			return errors.Annotate(err, "codec.ReadHeader error")
		case hdr.IsRequest():
			if err := conn.handleRequest(&hdr); err != nil {
				return errors.Annotatef(err, "codec.handleRequest %#v error", hdr)
			}
		default:
			if err := conn.handleResponse(&hdr); err != nil {
				return errors.Annotatef(err, "codec.handleResponse %#v error", hdr)
			}
		}
	}
}
// loop implements the looping part of Conn.input.
loop implements the looping part of Conn.input.
// loop implements the looping part of Conn . input .
func (conn *Conn) loop() error {
	defer conn.cancelContext()
	for {
		var hdr Header
		err := conn.codec.ReadHeader(&hdr)
		switch {
		case errors.Cause(err) == io.EOF:
			return err
		case err != nil:
			return errors.Annotate(err, "codec.ReadHeader error")
		case hdr.IsRequest():
			if err := conn.handleRequest(&hdr); err != nil {
				return errors.Annotatef(err, "codec.handleRequest %#v error", hdr)
			}
		default:
			if err := conn.handleResponse(&hdr); err != nil {
				return errors.Annotatef(err, "codec.handleResponse %#v error", hdr)
			}
		}
	}
}
func ( conn * Conn ) loop ( ) error { defer conn . cancelContext ( ) for { var hdr Header err := conn . codec . ReadHeader ( & hdr ) switch { case errors . Cause ( err ) == io . EOF : return err case err != nil : return errors . Annotate ( err , " " ) case hdr . IsRequest ( ) : if err := conn . handleRequest ( & hdr ) ; err != nil { return errors . Annotatef ( err , " " , hdr ) } default : if err := conn . handleResponse ( & hdr ) ; err != nil { return errors . Annotatef ( err , " " , hdr ) } } } }
loop implements the looping part of Conn.input.
loop implements the looping part of Conn . input .
// handle sentinel error specially