Debian Codegraph @

list_partition_reassignments_response.go

raw symbols SCIP
1 package sarama
2
3 import "time"
4
5 type PartitionReplicaReassignmentsStatus struct {
6 Replicas []int32
7 AddingReplicas []int32
8 RemovingReplicas []int32
9 }
10
11 func (b *PartitionReplicaReassignmentsStatus) encode(pe packetEncoder) error {
12 if err := pe.putInt32Array(b.Replicas); err != nil {
13 return err
14 }
15 if err := pe.putInt32Array(b.AddingReplicas); err != nil {
16 return err
17 }
18 if err := pe.putInt32Array(b.RemovingReplicas); err != nil {
19 return err
20 }
21
22 pe.putEmptyTaggedFieldArray()
23
24 return nil
25 }
26
27 func (b *PartitionReplicaReassignmentsStatus) decode(pd packetDecoder) (err error) {
28 if b.Replicas, err = pd.getInt32Array(); err != nil {
29 return err
30 }
31
32 if b.AddingReplicas, err = pd.getInt32Array(); err != nil {
33 return err
34 }
35
36 if b.RemovingReplicas, err = pd.getInt32Array(); err != nil {
37 return err
38 }
39
40 _, err = pd.getEmptyTaggedFieldArray()
41 return err
42 }
43
44 type ListPartitionReassignmentsResponse struct {
45 Version int16
46 ThrottleTimeMs int32
47 ErrorCode KError
48 ErrorMessage *string
49 TopicStatus map[string]map[int32]*PartitionReplicaReassignmentsStatus
50 }
51
52 func (r *ListPartitionReassignmentsResponse) setVersion(v int16) {
53 r.Version = v
54 }
55
56 func (r *ListPartitionReassignmentsResponse) AddBlock(topic string, partition int32, replicas, addingReplicas, removingReplicas []int32) {
57 if r.TopicStatus == nil {
58 r.TopicStatus = make(map[string]map[int32]*PartitionReplicaReassignmentsStatus)
59 }
60 partitions := r.TopicStatus[topic]
61 if partitions == nil {
62 partitions = make(map[int32]*PartitionReplicaReassignmentsStatus)
63 r.TopicStatus[topic] = partitions
64 }
65
66 partitions[partition] = &PartitionReplicaReassignmentsStatus{Replicas: replicas, AddingReplicas: addingReplicas, RemovingReplicas: removingReplicas}
67 }
68
69 func (r *ListPartitionReassignmentsResponse) encode(pe packetEncoder) error {
70 pe.putInt32(r.ThrottleTimeMs)
71 pe.putKError(r.ErrorCode)
72 if err := pe.putNullableString(r.ErrorMessage); err != nil {
73 return err
74 }
75
76 if err := pe.putArrayLength(len(r.TopicStatus)); err != nil {
77 return err
78 }
79 for topic, partitions := range r.TopicStatus {
80 if err := pe.putString(topic); err != nil {
81 return err
82 }
83 if err := pe.putArrayLength(len(partitions)); err != nil {
84 return err
85 }
86 for partition, block := range partitions {
87 pe.putInt32(partition)
88
89 if err := block.encode(pe); err != nil {
90 return err
91 }
92 }
93 pe.putEmptyTaggedFieldArray()
94 }
95
96 pe.putEmptyTaggedFieldArray()
97
98 return nil
99 }
100
101 func (r *ListPartitionReassignmentsResponse) decode(pd packetDecoder, version int16) (err error) {
102 r.Version = version
103
104 if r.ThrottleTimeMs, err = pd.getInt32(); err != nil {
105 return err
106 }
107
108 r.ErrorCode, err = pd.getKError()
109 if err != nil {
110 return err
111 }
112
113 if r.ErrorMessage, err = pd.getNullableString(); err != nil {
114 return err
115 }
116
117 numTopics, err := pd.getArrayLength()
118 if err != nil {
119 return err
120 }
121
122 r.TopicStatus = make(map[string]map[int32]*PartitionReplicaReassignmentsStatus, numTopics)
123 for i := 0; i < numTopics; i++ {
124 topic, err := pd.getString()
125 if err != nil {
126 return err
127 }
128
129 ongoingPartitionReassignments, err := pd.getArrayLength()
130 if err != nil {
131 return err
132 }
133
134 r.TopicStatus[topic] = make(map[int32]*PartitionReplicaReassignmentsStatus, ongoingPartitionReassignments)
135
136 for j := 0; j < ongoingPartitionReassignments; j++ {
137 partition, err := pd.getInt32()
138 if err != nil {
139 return err
140 }
141
142 block := &PartitionReplicaReassignmentsStatus{}
143 if err := block.decode(pd); err != nil {
144 return err
145 }
146 r.TopicStatus[topic][partition] = block
147 }
148
149 if _, err := pd.getEmptyTaggedFieldArray(); err != nil {
150 return err
151 }
152 }
153
154 _, err = pd.getEmptyTaggedFieldArray()
155 return err
156 }
157
158 func (r *ListPartitionReassignmentsResponse) key() int16 {
159 return apiKeyListPartitionReassignments
160 }
161
162 func (r *ListPartitionReassignmentsResponse) version() int16 {
163 return r.Version
164 }
165
166 func (r *ListPartitionReassignmentsResponse) headerVersion() int16 {
167 return 1
168 }
169
170 func (r *ListPartitionReassignmentsResponse) isValidVersion() bool {
171 return r.Version == 0
172 }
173
174 func (r *ListPartitionReassignmentsResponse) isFlexible() bool {
175 return r.isFlexibleVersion(r.Version)
176 }
177
178 func (r *ListPartitionReassignmentsResponse) isFlexibleVersion(version int16) bool {
179 return version >= 0
180 }
181
182 func (r *ListPartitionReassignmentsResponse) requiredVersion() KafkaVersion {
183 return V2_4_0_0
184 }
185
186 func (r *ListPartitionReassignmentsResponse) throttleTime() time.Duration {
187 return time.Duration(r.ThrottleTimeMs) * time.Millisecond
188 }