response_header.go 405 B

12345678910111213141516171819202122
  1. package protocol
  2. import "math"
  3. import enc "sarama/encoding"
  4. type responseHeader struct {
  5. length int32
  6. correlation_id int32
  7. }
  8. func (r *responseHeader) Decode(pd enc.PacketDecoder) (err error) {
  9. r.length, err = pd.GetInt32()
  10. if err != nil {
  11. return err
  12. }
  13. if r.length <= 4 || r.length > 2*math.MaxUint16 {
  14. return enc.DecodingError
  15. }
  16. r.correlation_id, err = pd.GetInt32()
  17. return err
  18. }