blob: 1f79c1255cb1dd67d8841aebbc60e5d4af0f1262 [file] [log] [blame]
khenaidooc6c7bda2020-06-17 17:20:18 -04001// Autogenerated by Thrift Compiler (0.9.3)
2// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
3
4package baggage
5
6import (
7 "bytes"
8 "fmt"
9 "github.com/uber/jaeger-client-go/thrift"
10)
11
12// (needed to ensure safety because of naive import list construction.)
13var _ = thrift.ZERO
14var _ = fmt.Printf
15var _ = bytes.Equal
16
17type BaggageRestrictionManager interface {
18 // getBaggageRestrictions retrieves the baggage restrictions for a specific service.
19 // Usually, baggageRestrictions apply to all services however there may be situations
20 // where a baggageKey might only be allowed to be set by a specific service.
21 //
22 // Parameters:
23 // - ServiceName
24 GetBaggageRestrictions(serviceName string) (r []*BaggageRestriction, err error)
25}
26
27type BaggageRestrictionManagerClient struct {
28 Transport thrift.TTransport
29 ProtocolFactory thrift.TProtocolFactory
30 InputProtocol thrift.TProtocol
31 OutputProtocol thrift.TProtocol
32 SeqId int32
33}
34
35func NewBaggageRestrictionManagerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BaggageRestrictionManagerClient {
36 return &BaggageRestrictionManagerClient{Transport: t,
37 ProtocolFactory: f,
38 InputProtocol: f.GetProtocol(t),
39 OutputProtocol: f.GetProtocol(t),
40 SeqId: 0,
41 }
42}
43
44func NewBaggageRestrictionManagerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BaggageRestrictionManagerClient {
45 return &BaggageRestrictionManagerClient{Transport: t,
46 ProtocolFactory: nil,
47 InputProtocol: iprot,
48 OutputProtocol: oprot,
49 SeqId: 0,
50 }
51}
52
53// getBaggageRestrictions retrieves the baggage restrictions for a specific service.
54// Usually, baggageRestrictions apply to all services however there may be situations
55// where a baggageKey might only be allowed to be set by a specific service.
56//
57// Parameters:
58// - ServiceName
59func (p *BaggageRestrictionManagerClient) GetBaggageRestrictions(serviceName string) (r []*BaggageRestriction, err error) {
60 if err = p.sendGetBaggageRestrictions(serviceName); err != nil {
61 return
62 }
63 return p.recvGetBaggageRestrictions()
64}
65
66func (p *BaggageRestrictionManagerClient) sendGetBaggageRestrictions(serviceName string) (err error) {
67 oprot := p.OutputProtocol
68 if oprot == nil {
69 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
70 p.OutputProtocol = oprot
71 }
72 p.SeqId++
73 if err = oprot.WriteMessageBegin("getBaggageRestrictions", thrift.CALL, p.SeqId); err != nil {
74 return
75 }
76 args := BaggageRestrictionManagerGetBaggageRestrictionsArgs{
77 ServiceName: serviceName,
78 }
79 if err = args.Write(oprot); err != nil {
80 return
81 }
82 if err = oprot.WriteMessageEnd(); err != nil {
83 return
84 }
85 return oprot.Flush()
86}
87
88func (p *BaggageRestrictionManagerClient) recvGetBaggageRestrictions() (value []*BaggageRestriction, err error) {
89 iprot := p.InputProtocol
90 if iprot == nil {
91 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
92 p.InputProtocol = iprot
93 }
94 method, mTypeId, seqId, err := iprot.ReadMessageBegin()
95 if err != nil {
96 return
97 }
98 if method != "getBaggageRestrictions" {
99 err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getBaggageRestrictions failed: wrong method name")
100 return
101 }
102 if p.SeqId != seqId {
103 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getBaggageRestrictions failed: out of sequence response")
104 return
105 }
106 if mTypeId == thrift.EXCEPTION {
107 error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
108 var error1 error
109 error1, err = error0.Read(iprot)
110 if err != nil {
111 return
112 }
113 if err = iprot.ReadMessageEnd(); err != nil {
114 return
115 }
116 err = error1
117 return
118 }
119 if mTypeId != thrift.REPLY {
120 err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getBaggageRestrictions failed: invalid message type")
121 return
122 }
123 result := BaggageRestrictionManagerGetBaggageRestrictionsResult{}
124 if err = result.Read(iprot); err != nil {
125 return
126 }
127 if err = iprot.ReadMessageEnd(); err != nil {
128 return
129 }
130 value = result.GetSuccess()
131 return
132}
133
134type BaggageRestrictionManagerProcessor struct {
135 processorMap map[string]thrift.TProcessorFunction
136 handler BaggageRestrictionManager
137}
138
139func (p *BaggageRestrictionManagerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
140 p.processorMap[key] = processor
141}
142
143func (p *BaggageRestrictionManagerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
144 processor, ok = p.processorMap[key]
145 return processor, ok
146}
147
148func (p *BaggageRestrictionManagerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
149 return p.processorMap
150}
151
152func NewBaggageRestrictionManagerProcessor(handler BaggageRestrictionManager) *BaggageRestrictionManagerProcessor {
153
154 self2 := &BaggageRestrictionManagerProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
155 self2.processorMap["getBaggageRestrictions"] = &baggageRestrictionManagerProcessorGetBaggageRestrictions{handler: handler}
156 return self2
157}
158
159func (p *BaggageRestrictionManagerProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
160 name, _, seqId, err := iprot.ReadMessageBegin()
161 if err != nil {
162 return false, err
163 }
164 if processor, ok := p.GetProcessorFunction(name); ok {
165 return processor.Process(seqId, iprot, oprot)
166 }
167 iprot.Skip(thrift.STRUCT)
168 iprot.ReadMessageEnd()
169 x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
170 oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
171 x3.Write(oprot)
172 oprot.WriteMessageEnd()
173 oprot.Flush()
174 return false, x3
175
176}
177
178type baggageRestrictionManagerProcessorGetBaggageRestrictions struct {
179 handler BaggageRestrictionManager
180}
181
182func (p *baggageRestrictionManagerProcessorGetBaggageRestrictions) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
183 args := BaggageRestrictionManagerGetBaggageRestrictionsArgs{}
184 if err = args.Read(iprot); err != nil {
185 iprot.ReadMessageEnd()
186 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
187 oprot.WriteMessageBegin("getBaggageRestrictions", thrift.EXCEPTION, seqId)
188 x.Write(oprot)
189 oprot.WriteMessageEnd()
190 oprot.Flush()
191 return false, err
192 }
193
194 iprot.ReadMessageEnd()
195 result := BaggageRestrictionManagerGetBaggageRestrictionsResult{}
196 var retval []*BaggageRestriction
197 var err2 error
198 if retval, err2 = p.handler.GetBaggageRestrictions(args.ServiceName); err2 != nil {
199 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getBaggageRestrictions: "+err2.Error())
200 oprot.WriteMessageBegin("getBaggageRestrictions", thrift.EXCEPTION, seqId)
201 x.Write(oprot)
202 oprot.WriteMessageEnd()
203 oprot.Flush()
204 return true, err2
205 } else {
206 result.Success = retval
207 }
208 if err2 = oprot.WriteMessageBegin("getBaggageRestrictions", thrift.REPLY, seqId); err2 != nil {
209 err = err2
210 }
211 if err2 = result.Write(oprot); err == nil && err2 != nil {
212 err = err2
213 }
214 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
215 err = err2
216 }
217 if err2 = oprot.Flush(); err == nil && err2 != nil {
218 err = err2
219 }
220 if err != nil {
221 return
222 }
223 return true, err
224}
225
226// HELPER FUNCTIONS AND STRUCTURES
227
228// Attributes:
229// - ServiceName
230type BaggageRestrictionManagerGetBaggageRestrictionsArgs struct {
231 ServiceName string `thrift:"serviceName,1" json:"serviceName"`
232}
233
234func NewBaggageRestrictionManagerGetBaggageRestrictionsArgs() *BaggageRestrictionManagerGetBaggageRestrictionsArgs {
235 return &BaggageRestrictionManagerGetBaggageRestrictionsArgs{}
236}
237
238func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) GetServiceName() string {
239 return p.ServiceName
240}
241func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) Read(iprot thrift.TProtocol) error {
242 if _, err := iprot.ReadStructBegin(); err != nil {
243 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
244 }
245
246 for {
247 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
248 if err != nil {
249 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
250 }
251 if fieldTypeId == thrift.STOP {
252 break
253 }
254 switch fieldId {
255 case 1:
256 if err := p.readField1(iprot); err != nil {
257 return err
258 }
259 default:
260 if err := iprot.Skip(fieldTypeId); err != nil {
261 return err
262 }
263 }
264 if err := iprot.ReadFieldEnd(); err != nil {
265 return err
266 }
267 }
268 if err := iprot.ReadStructEnd(); err != nil {
269 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
270 }
271 return nil
272}
273
274func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) readField1(iprot thrift.TProtocol) error {
275 if v, err := iprot.ReadString(); err != nil {
276 return thrift.PrependError("error reading field 1: ", err)
277 } else {
278 p.ServiceName = v
279 }
280 return nil
281}
282
283func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) Write(oprot thrift.TProtocol) error {
284 if err := oprot.WriteStructBegin("getBaggageRestrictions_args"); err != nil {
285 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
286 }
287 if err := p.writeField1(oprot); err != nil {
288 return err
289 }
290 if err := oprot.WriteFieldStop(); err != nil {
291 return thrift.PrependError("write field stop error: ", err)
292 }
293 if err := oprot.WriteStructEnd(); err != nil {
294 return thrift.PrependError("write struct stop error: ", err)
295 }
296 return nil
297}
298
299func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) writeField1(oprot thrift.TProtocol) (err error) {
300 if err := oprot.WriteFieldBegin("serviceName", thrift.STRING, 1); err != nil {
301 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:serviceName: ", p), err)
302 }
303 if err := oprot.WriteString(string(p.ServiceName)); err != nil {
304 return thrift.PrependError(fmt.Sprintf("%T.serviceName (1) field write error: ", p), err)
305 }
306 if err := oprot.WriteFieldEnd(); err != nil {
307 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:serviceName: ", p), err)
308 }
309 return err
310}
311
312func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) String() string {
313 if p == nil {
314 return "<nil>"
315 }
316 return fmt.Sprintf("BaggageRestrictionManagerGetBaggageRestrictionsArgs(%+v)", *p)
317}
318
319// Attributes:
320// - Success
321type BaggageRestrictionManagerGetBaggageRestrictionsResult struct {
322 Success []*BaggageRestriction `thrift:"success,0" json:"success,omitempty"`
323}
324
325func NewBaggageRestrictionManagerGetBaggageRestrictionsResult() *BaggageRestrictionManagerGetBaggageRestrictionsResult {
326 return &BaggageRestrictionManagerGetBaggageRestrictionsResult{}
327}
328
329var BaggageRestrictionManagerGetBaggageRestrictionsResult_Success_DEFAULT []*BaggageRestriction
330
331func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) GetSuccess() []*BaggageRestriction {
332 return p.Success
333}
334func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) IsSetSuccess() bool {
335 return p.Success != nil
336}
337
338func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) Read(iprot thrift.TProtocol) error {
339 if _, err := iprot.ReadStructBegin(); err != nil {
340 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
341 }
342
343 for {
344 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
345 if err != nil {
346 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
347 }
348 if fieldTypeId == thrift.STOP {
349 break
350 }
351 switch fieldId {
352 case 0:
353 if err := p.readField0(iprot); err != nil {
354 return err
355 }
356 default:
357 if err := iprot.Skip(fieldTypeId); err != nil {
358 return err
359 }
360 }
361 if err := iprot.ReadFieldEnd(); err != nil {
362 return err
363 }
364 }
365 if err := iprot.ReadStructEnd(); err != nil {
366 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
367 }
368 return nil
369}
370
371func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) readField0(iprot thrift.TProtocol) error {
372 _, size, err := iprot.ReadListBegin()
373 if err != nil {
374 return thrift.PrependError("error reading list begin: ", err)
375 }
376 tSlice := make([]*BaggageRestriction, 0, size)
377 p.Success = tSlice
378 for i := 0; i < size; i++ {
379 _elem4 := &BaggageRestriction{}
380 if err := _elem4.Read(iprot); err != nil {
381 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem4), err)
382 }
383 p.Success = append(p.Success, _elem4)
384 }
385 if err := iprot.ReadListEnd(); err != nil {
386 return thrift.PrependError("error reading list end: ", err)
387 }
388 return nil
389}
390
391func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) Write(oprot thrift.TProtocol) error {
392 if err := oprot.WriteStructBegin("getBaggageRestrictions_result"); err != nil {
393 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
394 }
395 if err := p.writeField0(oprot); err != nil {
396 return err
397 }
398 if err := oprot.WriteFieldStop(); err != nil {
399 return thrift.PrependError("write field stop error: ", err)
400 }
401 if err := oprot.WriteStructEnd(); err != nil {
402 return thrift.PrependError("write struct stop error: ", err)
403 }
404 return nil
405}
406
407func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) writeField0(oprot thrift.TProtocol) (err error) {
408 if p.IsSetSuccess() {
409 if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil {
410 return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err)
411 }
412 if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil {
413 return thrift.PrependError("error writing list begin: ", err)
414 }
415 for _, v := range p.Success {
416 if err := v.Write(oprot); err != nil {
417 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err)
418 }
419 }
420 if err := oprot.WriteListEnd(); err != nil {
421 return thrift.PrependError("error writing list end: ", err)
422 }
423 if err := oprot.WriteFieldEnd(); err != nil {
424 return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err)
425 }
426 }
427 return err
428}
429
430func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) String() string {
431 if p == nil {
432 return "<nil>"
433 }
434 return fmt.Sprintf("BaggageRestrictionManagerGetBaggageRestrictionsResult(%+v)", *p)
435}