response_header.go 437 B

123456789101112131415161718192021
  1. package sarama
  2. import "fmt"
  3. type responseHeader struct {
  4. length int32
  5. correlationID int32
  6. }
  7. func (r *responseHeader) decode(pd packetDecoder) (err error) {
  8. r.length, err = pd.getInt32()
  9. if err != nil {
  10. return err
  11. }
  12. if r.length <= 4 || r.length > MaxResponseSize {
  13. return PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", r.length)}
  14. }
  15. r.correlationID, err = pd.getInt32()
  16. return err
  17. }