end_txn_response.go 834 B

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