response_header.go 612 B

123456789101112131415161718192021222324252627282930313233
  1. package sarama
  2. import "fmt"
  3. const (
  4. responseLengthSize = 4
  5. correlationIDSize = 4
  6. )
  7. type responseHeader struct {
  8. length int32
  9. correlationID int32
  10. }
  11. func (r *responseHeader) decode(pd packetDecoder, version int16) (err error) {
  12. r.length, err = pd.getInt32()
  13. if err != nil {
  14. return err
  15. }
  16. if r.length <= 4 || r.length > MaxResponseSize {
  17. return PacketDecodingError{fmt.Sprintf("message of length %d too large or too small", r.length)}
  18. }
  19. r.correlationID, err = pd.getInt32()
  20. if version >= 1 {
  21. if _, err := pd.getEmptyTaggedFieldArray(); err != nil {
  22. return err
  23. }
  24. }
  25. return err
  26. }