delete_topics_request.go 903 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package sarama
  2. import "time"
  3. type DeleteTopicsRequest struct {
  4. Version int16
  5. Topics []string
  6. Timeout time.Duration
  7. }
  8. func (d *DeleteTopicsRequest) encode(pe packetEncoder) error {
  9. if err := pe.putStringArray(d.Topics); err != nil {
  10. return err
  11. }
  12. pe.putInt32(int32(d.Timeout / time.Millisecond))
  13. return nil
  14. }
  15. func (d *DeleteTopicsRequest) decode(pd packetDecoder, version int16) (err error) {
  16. if d.Topics, err = pd.getStringArray(); err != nil {
  17. return err
  18. }
  19. timeout, err := pd.getInt32()
  20. if err != nil {
  21. return err
  22. }
  23. d.Timeout = time.Duration(timeout) * time.Millisecond
  24. d.Version = version
  25. return nil
  26. }
  27. func (d *DeleteTopicsRequest) key() int16 {
  28. return 20
  29. }
  30. func (d *DeleteTopicsRequest) version() int16 {
  31. return d.Version
  32. }
  33. func (d *DeleteTopicsRequest) requiredVersion() KafkaVersion {
  34. switch d.Version {
  35. case 1:
  36. return V0_11_0_0
  37. default:
  38. return V0_10_1_0
  39. }
  40. }