blob: 597bcbf786f55c4c496a7be27a67fcdd1bae050f [file] [log] [blame]
khenaidooac637102019-01-14 15:44:34 -05001package sarama
2
3type CoordinatorType int8
4
5const (
Scott Baker8461e152019-10-01 14:44:30 -07006 CoordinatorGroup CoordinatorType = iota
7 CoordinatorTransaction
khenaidooac637102019-01-14 15:44:34 -05008)
9
10type FindCoordinatorRequest struct {
11 Version int16
12 CoordinatorKey string
13 CoordinatorType CoordinatorType
14}
15
16func (f *FindCoordinatorRequest) encode(pe packetEncoder) error {
17 if err := pe.putString(f.CoordinatorKey); err != nil {
18 return err
19 }
20
21 if f.Version >= 1 {
22 pe.putInt8(int8(f.CoordinatorType))
23 }
24
25 return nil
26}
27
28func (f *FindCoordinatorRequest) decode(pd packetDecoder, version int16) (err error) {
29 if f.CoordinatorKey, err = pd.getString(); err != nil {
30 return err
31 }
32
33 if version >= 1 {
34 f.Version = version
35 coordinatorType, err := pd.getInt8()
36 if err != nil {
37 return err
38 }
39
40 f.CoordinatorType = CoordinatorType(coordinatorType)
41 }
42
43 return nil
44}
45
46func (f *FindCoordinatorRequest) key() int16 {
47 return 10
48}
49
50func (f *FindCoordinatorRequest) version() int16 {
51 return f.Version
52}
53
khenaidood948f772021-08-11 17:49:24 -040054func (r *FindCoordinatorRequest) headerVersion() int16 {
55 return 1
56}
57
khenaidooac637102019-01-14 15:44:34 -050058func (f *FindCoordinatorRequest) requiredVersion() KafkaVersion {
59 switch f.Version {
60 case 1:
61 return V0_11_0_0
62 default:
63 return V0_8_2_0
64 }
65}