offset_commit_response.go 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package protocol
  2. import enc "sarama/encoding"
  3. import "sarama/types"
  4. type OffsetCommitResponse struct {
  5. ClientID string
  6. Errors map[string]map[int32]types.KError
  7. }
  8. func (r *OffsetCommitResponse) Decode(pd enc.PacketDecoder) (err error) {
  9. r.ClientID, err = pd.GetString()
  10. if err != nil {
  11. return err
  12. }
  13. numTopics, err := pd.GetArrayLength()
  14. if err != nil {
  15. return err
  16. }
  17. r.Errors = make(map[string]map[int32]types.KError, numTopics)
  18. for i := 0; i < numTopics; i++ {
  19. name, err := pd.GetString()
  20. if err != nil {
  21. return err
  22. }
  23. numErrors, err := pd.GetArrayLength()
  24. if err != nil {
  25. return err
  26. }
  27. r.Errors[name] = make(map[int32]types.KError, numErrors)
  28. for j := 0; j < numErrors; j++ {
  29. id, err := pd.GetInt32()
  30. if err != nil {
  31. return err
  32. }
  33. tmp, err := pd.GetInt16()
  34. if err != nil {
  35. return err
  36. }
  37. r.Errors[name][id] = types.KError(tmp)
  38. }
  39. }
  40. return nil
  41. }