blob: 597bcbf786f55c4c496a7be27a67fcdd1bae050f [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001package sarama
2
3type CoordinatorType int8
4
5const (
6 CoordinatorGroup CoordinatorType = iota
7 CoordinatorTransaction
8)
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
khenaidoo7d3c5582021-08-11 18:09:44 -040054func (r *FindCoordinatorRequest) headerVersion() int16 {
55 return 1
56}
57
Holger Hildebrandtfa074992020-03-27 15:42:06 +000058func (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}