add_offsets_to_txn_request.go 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package sarama
  2. type AddOffsetsToTxnRequest struct {
  3. TransactionalID string
  4. ProducerID int64
  5. ProducerEpoch int16
  6. GroupID string
  7. }
  8. func (a *AddOffsetsToTxnRequest) 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. if err := pe.putString(a.GroupID); err != nil {
  15. return err
  16. }
  17. return nil
  18. }
  19. func (a *AddOffsetsToTxnRequest) decode(pd packetDecoder, version int16) (err error) {
  20. if a.TransactionalID, err = pd.getString(); err != nil {
  21. return err
  22. }
  23. if a.ProducerID, err = pd.getInt64(); err != nil {
  24. return err
  25. }
  26. if a.ProducerEpoch, err = pd.getInt16(); err != nil {
  27. return err
  28. }
  29. if a.GroupID, err = pd.getString(); err != nil {
  30. return err
  31. }
  32. return nil
  33. }
  34. func (a *AddOffsetsToTxnRequest) key() int16 {
  35. return 25
  36. }
  37. func (a *AddOffsetsToTxnRequest) version() int16 {
  38. return 0
  39. }
  40. func (a *AddOffsetsToTxnRequest) requiredVersion() KafkaVersion {
  41. return V0_11_0_0
  42. }