blob: fc227ab86899264c061c8317f618d54861c8dd3b [file] [log] [blame]
Scott Bakered4efab2020-01-13 19:12:25 -08001package sarama
2
3//AddOffsetsToTxnRequest adds offsets to a transaction request
4type AddOffsetsToTxnRequest struct {
5 TransactionalID string
6 ProducerID int64
7 ProducerEpoch int16
8 GroupID string
9}
10
11func (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
27func (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
43func (a *AddOffsetsToTxnRequest) key() int16 {
44 return 25
45}
46
47func (a *AddOffsetsToTxnRequest) version() int16 {
48 return 0
49}
50
51func (a *AddOffsetsToTxnRequest) requiredVersion() KafkaVersion {
52 return V0_11_0_0
53}