end_txn_request.go 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package sarama
  2. type EndTxnRequest struct {
  3. TransactionalID string
  4. ProducerID int64
  5. ProducerEpoch int16
  6. TransactionResult bool
  7. }
  8. func (a *EndTxnRequest) encode(pe packetEncoder) error {
  9. if err := pe.putString(a.TransactionalID); err != nil {
  10. return err
  11. }
  12. pe.putInt64(a.ProducerID)
  13. pe.putInt16(a.ProducerEpoch)
  14. pe.putBool(a.TransactionResult)
  15. return nil
  16. }
  17. func (a *EndTxnRequest) decode(pd packetDecoder, version int16) (err error) {
  18. if a.TransactionalID, err = pd.getString(); err != nil {
  19. return err
  20. }
  21. if a.ProducerID, err = pd.getInt64(); err != nil {
  22. return err
  23. }
  24. if a.ProducerEpoch, err = pd.getInt16(); err != nil {
  25. return err
  26. }
  27. if a.TransactionResult, err = pd.getBool(); err != nil {
  28. return err
  29. }
  30. return nil
  31. }
  32. func (a *EndTxnRequest) key() int16 {
  33. return 26
  34. }
  35. func (a *EndTxnRequest) version() int16 {
  36. return 0
  37. }
  38. func (r *EndTxnRequest) headerVersion() int16 {
  39. return 1
  40. }
  41. func (a *EndTxnRequest) requiredVersion() KafkaVersion {
  42. return V0_11_0_0
  43. }