add_offsets_to_txn_response.go 826 B

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