end_txn_response.go 772 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 (e *EndTxnResponse) requiredVersion() KafkaVersion {
  34. return V0_11_0_0
  35. }