add_offsets_to_txn_response.go 898 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package sarama
  2. import (
  3. "time"
  4. )
  5. //AddOffsetsToTxnResponse is a response type for adding offsets to txns
  6. type AddOffsetsToTxnResponse struct {
  7. ThrottleTime time.Duration
  8. Err KError
  9. }
  10. func (a *AddOffsetsToTxnResponse) encode(pe packetEncoder) error {
  11. pe.putInt32(int32(a.ThrottleTime / time.Millisecond))
  12. pe.putInt16(int16(a.Err))
  13. return nil
  14. }
  15. func (a *AddOffsetsToTxnResponse) decode(pd packetDecoder, version int16) (err error) {
  16. throttleTime, err := pd.getInt32()
  17. if err != nil {
  18. return err
  19. }
  20. a.ThrottleTime = time.Duration(throttleTime) * time.Millisecond
  21. kerr, err := pd.getInt16()
  22. if err != nil {
  23. return err
  24. }
  25. a.Err = KError(kerr)
  26. return nil
  27. }
  28. func (a *AddOffsetsToTxnResponse) key() int16 {
  29. return 25
  30. }
  31. func (a *AddOffsetsToTxnResponse) version() int16 {
  32. return 0
  33. }
  34. func (a *AddOffsetsToTxnResponse) requiredVersion() KafkaVersion {
  35. return V0_11_0_0
  36. }