add_offsets_to_txn_response.go 969 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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) headerVersion() int16 {
  35. return 0
  36. }
  37. func (a *AddOffsetsToTxnResponse) requiredVersion() KafkaVersion {
  38. return V0_11_0_0
  39. }