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