William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 1 | package sarama |
| 2 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 3 | // AddOffsetsToTxnRequest adds offsets to a transaction request |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 4 | type AddOffsetsToTxnRequest struct { |
| 5 | TransactionalID string |
| 6 | ProducerID int64 |
| 7 | ProducerEpoch int16 |
| 8 | GroupID string |
| 9 | } |
| 10 | |
| 11 | func (a *AddOffsetsToTxnRequest) encode(pe packetEncoder) error { |
| 12 | if err := pe.putString(a.TransactionalID); err != nil { |
| 13 | return err |
| 14 | } |
| 15 | |
| 16 | pe.putInt64(a.ProducerID) |
| 17 | |
| 18 | pe.putInt16(a.ProducerEpoch) |
| 19 | |
| 20 | if err := pe.putString(a.GroupID); err != nil { |
| 21 | return err |
| 22 | } |
| 23 | |
| 24 | return nil |
| 25 | } |
| 26 | |
| 27 | func (a *AddOffsetsToTxnRequest) decode(pd packetDecoder, version int16) (err error) { |
| 28 | if a.TransactionalID, err = pd.getString(); err != nil { |
| 29 | return err |
| 30 | } |
| 31 | if a.ProducerID, err = pd.getInt64(); err != nil { |
| 32 | return err |
| 33 | } |
| 34 | if a.ProducerEpoch, err = pd.getInt16(); err != nil { |
| 35 | return err |
| 36 | } |
| 37 | if a.GroupID, err = pd.getString(); err != nil { |
| 38 | return err |
| 39 | } |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | func (a *AddOffsetsToTxnRequest) key() int16 { |
| 44 | return 25 |
| 45 | } |
| 46 | |
| 47 | func (a *AddOffsetsToTxnRequest) version() int16 { |
| 48 | return 0 |
| 49 | } |
| 50 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 51 | func (a *AddOffsetsToTxnRequest) headerVersion() int16 { |
| 52 | return 1 |
| 53 | } |
| 54 | |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 55 | func (a *AddOffsetsToTxnRequest) requiredVersion() KafkaVersion { |
| 56 | return V0_11_0_0 |
| 57 | } |