offset_commit_response.go 751 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package sarama
  2. type OffsetCommitResponse struct {
  3. Errors map[string]map[int32]KError
  4. }
  5. func (r *OffsetCommitResponse) decode(pd packetDecoder) (err error) {
  6. numTopics, err := pd.getArrayLength()
  7. if err != nil {
  8. return err
  9. }
  10. r.Errors = make(map[string]map[int32]KError, numTopics)
  11. for i := 0; i < numTopics; i++ {
  12. name, err := pd.getString()
  13. if err != nil {
  14. return err
  15. }
  16. numErrors, err := pd.getArrayLength()
  17. if err != nil {
  18. return err
  19. }
  20. r.Errors[name] = make(map[int32]KError, numErrors)
  21. for j := 0; j < numErrors; j++ {
  22. id, err := pd.getInt32()
  23. if err != nil {
  24. return err
  25. }
  26. tmp, err := pd.getInt16()
  27. if err != nil {
  28. return err
  29. }
  30. r.Errors[name][id] = KError(tmp)
  31. }
  32. }
  33. return nil
  34. }