describe_groups_request.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package sarama
  2. type DescribeGroupsRequest struct {
  3. Version int16
  4. Groups []string
  5. IncludeAuthorizedOperations bool
  6. }
  7. func (r *DescribeGroupsRequest) encode(pe packetEncoder) error {
  8. if err := pe.putStringArray(r.Groups); err != nil {
  9. return err
  10. }
  11. if r.Version >= 3 {
  12. pe.putBool(r.IncludeAuthorizedOperations)
  13. }
  14. return nil
  15. }
  16. func (r *DescribeGroupsRequest) decode(pd packetDecoder, version int16) (err error) {
  17. r.Version = version
  18. r.Groups, err = pd.getStringArray()
  19. if err != nil {
  20. return err
  21. }
  22. if r.Version >= 3 {
  23. if r.IncludeAuthorizedOperations, err = pd.getBool(); err != nil {
  24. return err
  25. }
  26. }
  27. return nil
  28. }
  29. func (r *DescribeGroupsRequest) key() int16 {
  30. return 15
  31. }
  32. func (r *DescribeGroupsRequest) version() int16 {
  33. return r.Version
  34. }
  35. func (r *DescribeGroupsRequest) headerVersion() int16 {
  36. return 1
  37. }
  38. func (r *DescribeGroupsRequest) isValidVersion() bool {
  39. return r.Version >= 0 && r.Version <= 4
  40. }
  41. func (r *DescribeGroupsRequest) requiredVersion() KafkaVersion {
  42. switch r.Version {
  43. case 4:
  44. return V2_4_0_0
  45. case 3:
  46. return V2_3_0_0
  47. case 2:
  48. return V2_0_0_0
  49. case 1:
  50. return V0_11_0_0
  51. case 0:
  52. return V0_9_0_0
  53. default:
  54. return V2_4_0_0
  55. }
  56. }
  57. func (r *DescribeGroupsRequest) AddGroup(group string) {
  58. r.Groups = append(r.Groups, group)
  59. }