offset_commit_response.go 866 B

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