response_header.go 495 B

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