blob: 3bffa5b8eea977cef812c4331885d9ec330ad99a [file] [log] [blame]
khenaidood948f772021-08-11 17:49:24 -04001// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT.
2
3package sampling
4
5import(
6 "bytes"
7 "context"
8 "database/sql/driver"
9 "errors"
10 "fmt"
11 "time"
12 "github.com/uber/jaeger-client-go/thrift"
13)
14
15// (needed to ensure safety because of naive import list construction.)
16var _ = thrift.ZERO
17var _ = fmt.Printf
18var _ = context.Background
19var _ = time.Now
20var _ = bytes.Equal
21
22type SamplingStrategyType int64
23const (
24 SamplingStrategyType_PROBABILISTIC SamplingStrategyType = 0
25 SamplingStrategyType_RATE_LIMITING SamplingStrategyType = 1
26)
27
28func (p SamplingStrategyType) String() string {
29 switch p {
30 case SamplingStrategyType_PROBABILISTIC: return "PROBABILISTIC"
31 case SamplingStrategyType_RATE_LIMITING: return "RATE_LIMITING"
32 }
33 return "<UNSET>"
34}
35
36func SamplingStrategyTypeFromString(s string) (SamplingStrategyType, error) {
37 switch s {
38 case "PROBABILISTIC": return SamplingStrategyType_PROBABILISTIC, nil
39 case "RATE_LIMITING": return SamplingStrategyType_RATE_LIMITING, nil
40 }
41 return SamplingStrategyType(0), fmt.Errorf("not a valid SamplingStrategyType string")
42}
43
44
45func SamplingStrategyTypePtr(v SamplingStrategyType) *SamplingStrategyType { return &v }
46
47func (p SamplingStrategyType) MarshalText() ([]byte, error) {
48return []byte(p.String()), nil
49}
50
51func (p *SamplingStrategyType) UnmarshalText(text []byte) error {
52q, err := SamplingStrategyTypeFromString(string(text))
53if (err != nil) {
54return err
55}
56*p = q
57return nil
58}
59
60func (p *SamplingStrategyType) Scan(value interface{}) error {
61v, ok := value.(int64)
62if !ok {
63return errors.New("Scan value is not int64")
64}
65*p = SamplingStrategyType(v)
66return nil
67}
68
69func (p * SamplingStrategyType) Value() (driver.Value, error) {
70 if p == nil {
71 return nil, nil
72 }
73return int64(*p), nil
74}
75// Attributes:
76// - SamplingRate
77type ProbabilisticSamplingStrategy struct {
78 SamplingRate float64 `thrift:"samplingRate,1,required" db:"samplingRate" json:"samplingRate"`
79}
80
81func NewProbabilisticSamplingStrategy() *ProbabilisticSamplingStrategy {
82 return &ProbabilisticSamplingStrategy{}
83}
84
85
86func (p *ProbabilisticSamplingStrategy) GetSamplingRate() float64 {
87 return p.SamplingRate
88}
89func (p *ProbabilisticSamplingStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error {
90 if _, err := iprot.ReadStructBegin(ctx); err != nil {
91 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
92 }
93
94 var issetSamplingRate bool = false;
95
96 for {
97 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
98 if err != nil {
99 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
100 }
101 if fieldTypeId == thrift.STOP { break; }
102 switch fieldId {
103 case 1:
104 if fieldTypeId == thrift.DOUBLE {
105 if err := p.ReadField1(ctx, iprot); err != nil {
106 return err
107 }
108 issetSamplingRate = true
109 } else {
110 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
111 return err
112 }
113 }
114 default:
115 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
116 return err
117 }
118 }
119 if err := iprot.ReadFieldEnd(ctx); err != nil {
120 return err
121 }
122 }
123 if err := iprot.ReadStructEnd(ctx); err != nil {
124 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
125 }
126 if !issetSamplingRate{
127 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field SamplingRate is not set"));
128 }
129 return nil
130}
131
132func (p *ProbabilisticSamplingStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
133 if v, err := iprot.ReadDouble(ctx); err != nil {
134 return thrift.PrependError("error reading field 1: ", err)
135} else {
136 p.SamplingRate = v
137}
138 return nil
139}
140
141func (p *ProbabilisticSamplingStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error {
142 if err := oprot.WriteStructBegin(ctx, "ProbabilisticSamplingStrategy"); err != nil {
143 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
144 if p != nil {
145 if err := p.writeField1(ctx, oprot); err != nil { return err }
146 }
147 if err := oprot.WriteFieldStop(ctx); err != nil {
148 return thrift.PrependError("write field stop error: ", err) }
149 if err := oprot.WriteStructEnd(ctx); err != nil {
150 return thrift.PrependError("write struct stop error: ", err) }
151 return nil
152}
153
154func (p *ProbabilisticSamplingStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
155 if err := oprot.WriteFieldBegin(ctx, "samplingRate", thrift.DOUBLE, 1); err != nil {
156 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:samplingRate: ", p), err) }
157 if err := oprot.WriteDouble(ctx, float64(p.SamplingRate)); err != nil {
158 return thrift.PrependError(fmt.Sprintf("%T.samplingRate (1) field write error: ", p), err) }
159 if err := oprot.WriteFieldEnd(ctx); err != nil {
160 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:samplingRate: ", p), err) }
161 return err
162}
163
164func (p *ProbabilisticSamplingStrategy) Equals(other *ProbabilisticSamplingStrategy) bool {
165 if p == other {
166 return true
167 } else if p == nil || other == nil {
168 return false
169 }
170 if p.SamplingRate != other.SamplingRate { return false }
171 return true
172}
173
174func (p *ProbabilisticSamplingStrategy) String() string {
175 if p == nil {
176 return "<nil>"
177 }
178 return fmt.Sprintf("ProbabilisticSamplingStrategy(%+v)", *p)
179}
180
181// Attributes:
182// - MaxTracesPerSecond
183type RateLimitingSamplingStrategy struct {
184 MaxTracesPerSecond int16 `thrift:"maxTracesPerSecond,1,required" db:"maxTracesPerSecond" json:"maxTracesPerSecond"`
185}
186
187func NewRateLimitingSamplingStrategy() *RateLimitingSamplingStrategy {
188 return &RateLimitingSamplingStrategy{}
189}
190
191
192func (p *RateLimitingSamplingStrategy) GetMaxTracesPerSecond() int16 {
193 return p.MaxTracesPerSecond
194}
195func (p *RateLimitingSamplingStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error {
196 if _, err := iprot.ReadStructBegin(ctx); err != nil {
197 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
198 }
199
200 var issetMaxTracesPerSecond bool = false;
201
202 for {
203 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
204 if err != nil {
205 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
206 }
207 if fieldTypeId == thrift.STOP { break; }
208 switch fieldId {
209 case 1:
210 if fieldTypeId == thrift.I16 {
211 if err := p.ReadField1(ctx, iprot); err != nil {
212 return err
213 }
214 issetMaxTracesPerSecond = true
215 } else {
216 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
217 return err
218 }
219 }
220 default:
221 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
222 return err
223 }
224 }
225 if err := iprot.ReadFieldEnd(ctx); err != nil {
226 return err
227 }
228 }
229 if err := iprot.ReadStructEnd(ctx); err != nil {
230 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
231 }
232 if !issetMaxTracesPerSecond{
233 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field MaxTracesPerSecond is not set"));
234 }
235 return nil
236}
237
238func (p *RateLimitingSamplingStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
239 if v, err := iprot.ReadI16(ctx); err != nil {
240 return thrift.PrependError("error reading field 1: ", err)
241} else {
242 p.MaxTracesPerSecond = v
243}
244 return nil
245}
246
247func (p *RateLimitingSamplingStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error {
248 if err := oprot.WriteStructBegin(ctx, "RateLimitingSamplingStrategy"); err != nil {
249 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
250 if p != nil {
251 if err := p.writeField1(ctx, oprot); err != nil { return err }
252 }
253 if err := oprot.WriteFieldStop(ctx); err != nil {
254 return thrift.PrependError("write field stop error: ", err) }
255 if err := oprot.WriteStructEnd(ctx); err != nil {
256 return thrift.PrependError("write struct stop error: ", err) }
257 return nil
258}
259
260func (p *RateLimitingSamplingStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
261 if err := oprot.WriteFieldBegin(ctx, "maxTracesPerSecond", thrift.I16, 1); err != nil {
262 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:maxTracesPerSecond: ", p), err) }
263 if err := oprot.WriteI16(ctx, int16(p.MaxTracesPerSecond)); err != nil {
264 return thrift.PrependError(fmt.Sprintf("%T.maxTracesPerSecond (1) field write error: ", p), err) }
265 if err := oprot.WriteFieldEnd(ctx); err != nil {
266 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:maxTracesPerSecond: ", p), err) }
267 return err
268}
269
270func (p *RateLimitingSamplingStrategy) Equals(other *RateLimitingSamplingStrategy) bool {
271 if p == other {
272 return true
273 } else if p == nil || other == nil {
274 return false
275 }
276 if p.MaxTracesPerSecond != other.MaxTracesPerSecond { return false }
277 return true
278}
279
280func (p *RateLimitingSamplingStrategy) String() string {
281 if p == nil {
282 return "<nil>"
283 }
284 return fmt.Sprintf("RateLimitingSamplingStrategy(%+v)", *p)
285}
286
287// Attributes:
288// - Operation
289// - ProbabilisticSampling
290type OperationSamplingStrategy struct {
291 Operation string `thrift:"operation,1,required" db:"operation" json:"operation"`
292 ProbabilisticSampling *ProbabilisticSamplingStrategy `thrift:"probabilisticSampling,2,required" db:"probabilisticSampling" json:"probabilisticSampling"`
293}
294
295func NewOperationSamplingStrategy() *OperationSamplingStrategy {
296 return &OperationSamplingStrategy{}
297}
298
299
300func (p *OperationSamplingStrategy) GetOperation() string {
301 return p.Operation
302}
303var OperationSamplingStrategy_ProbabilisticSampling_DEFAULT *ProbabilisticSamplingStrategy
304func (p *OperationSamplingStrategy) GetProbabilisticSampling() *ProbabilisticSamplingStrategy {
305 if !p.IsSetProbabilisticSampling() {
306 return OperationSamplingStrategy_ProbabilisticSampling_DEFAULT
307 }
308return p.ProbabilisticSampling
309}
310func (p *OperationSamplingStrategy) IsSetProbabilisticSampling() bool {
311 return p.ProbabilisticSampling != nil
312}
313
314func (p *OperationSamplingStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error {
315 if _, err := iprot.ReadStructBegin(ctx); err != nil {
316 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
317 }
318
319 var issetOperation bool = false;
320 var issetProbabilisticSampling bool = false;
321
322 for {
323 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
324 if err != nil {
325 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
326 }
327 if fieldTypeId == thrift.STOP { break; }
328 switch fieldId {
329 case 1:
330 if fieldTypeId == thrift.STRING {
331 if err := p.ReadField1(ctx, iprot); err != nil {
332 return err
333 }
334 issetOperation = true
335 } else {
336 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
337 return err
338 }
339 }
340 case 2:
341 if fieldTypeId == thrift.STRUCT {
342 if err := p.ReadField2(ctx, iprot); err != nil {
343 return err
344 }
345 issetProbabilisticSampling = true
346 } else {
347 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
348 return err
349 }
350 }
351 default:
352 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
353 return err
354 }
355 }
356 if err := iprot.ReadFieldEnd(ctx); err != nil {
357 return err
358 }
359 }
360 if err := iprot.ReadStructEnd(ctx); err != nil {
361 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
362 }
363 if !issetOperation{
364 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Operation is not set"));
365 }
366 if !issetProbabilisticSampling{
367 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field ProbabilisticSampling is not set"));
368 }
369 return nil
370}
371
372func (p *OperationSamplingStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
373 if v, err := iprot.ReadString(ctx); err != nil {
374 return thrift.PrependError("error reading field 1: ", err)
375} else {
376 p.Operation = v
377}
378 return nil
379}
380
381func (p *OperationSamplingStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
382 p.ProbabilisticSampling = &ProbabilisticSamplingStrategy{}
383 if err := p.ProbabilisticSampling.Read(ctx, iprot); err != nil {
384 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProbabilisticSampling), err)
385 }
386 return nil
387}
388
389func (p *OperationSamplingStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error {
390 if err := oprot.WriteStructBegin(ctx, "OperationSamplingStrategy"); err != nil {
391 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
392 if p != nil {
393 if err := p.writeField1(ctx, oprot); err != nil { return err }
394 if err := p.writeField2(ctx, oprot); err != nil { return err }
395 }
396 if err := oprot.WriteFieldStop(ctx); err != nil {
397 return thrift.PrependError("write field stop error: ", err) }
398 if err := oprot.WriteStructEnd(ctx); err != nil {
399 return thrift.PrependError("write struct stop error: ", err) }
400 return nil
401}
402
403func (p *OperationSamplingStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
404 if err := oprot.WriteFieldBegin(ctx, "operation", thrift.STRING, 1); err != nil {
405 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:operation: ", p), err) }
406 if err := oprot.WriteString(ctx, string(p.Operation)); err != nil {
407 return thrift.PrependError(fmt.Sprintf("%T.operation (1) field write error: ", p), err) }
408 if err := oprot.WriteFieldEnd(ctx); err != nil {
409 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:operation: ", p), err) }
410 return err
411}
412
413func (p *OperationSamplingStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
414 if err := oprot.WriteFieldBegin(ctx, "probabilisticSampling", thrift.STRUCT, 2); err != nil {
415 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:probabilisticSampling: ", p), err) }
416 if err := p.ProbabilisticSampling.Write(ctx, oprot); err != nil {
417 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProbabilisticSampling), err)
418 }
419 if err := oprot.WriteFieldEnd(ctx); err != nil {
420 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:probabilisticSampling: ", p), err) }
421 return err
422}
423
424func (p *OperationSamplingStrategy) Equals(other *OperationSamplingStrategy) bool {
425 if p == other {
426 return true
427 } else if p == nil || other == nil {
428 return false
429 }
430 if p.Operation != other.Operation { return false }
431 if !p.ProbabilisticSampling.Equals(other.ProbabilisticSampling) { return false }
432 return true
433}
434
435func (p *OperationSamplingStrategy) String() string {
436 if p == nil {
437 return "<nil>"
438 }
439 return fmt.Sprintf("OperationSamplingStrategy(%+v)", *p)
440}
441
442// Attributes:
443// - DefaultSamplingProbability
444// - DefaultLowerBoundTracesPerSecond
445// - PerOperationStrategies
446// - DefaultUpperBoundTracesPerSecond
447type PerOperationSamplingStrategies struct {
448 DefaultSamplingProbability float64 `thrift:"defaultSamplingProbability,1,required" db:"defaultSamplingProbability" json:"defaultSamplingProbability"`
449 DefaultLowerBoundTracesPerSecond float64 `thrift:"defaultLowerBoundTracesPerSecond,2,required" db:"defaultLowerBoundTracesPerSecond" json:"defaultLowerBoundTracesPerSecond"`
450 PerOperationStrategies []*OperationSamplingStrategy `thrift:"perOperationStrategies,3,required" db:"perOperationStrategies" json:"perOperationStrategies"`
451 DefaultUpperBoundTracesPerSecond *float64 `thrift:"defaultUpperBoundTracesPerSecond,4" db:"defaultUpperBoundTracesPerSecond" json:"defaultUpperBoundTracesPerSecond,omitempty"`
452}
453
454func NewPerOperationSamplingStrategies() *PerOperationSamplingStrategies {
455 return &PerOperationSamplingStrategies{}
456}
457
458
459func (p *PerOperationSamplingStrategies) GetDefaultSamplingProbability() float64 {
460 return p.DefaultSamplingProbability
461}
462
463func (p *PerOperationSamplingStrategies) GetDefaultLowerBoundTracesPerSecond() float64 {
464 return p.DefaultLowerBoundTracesPerSecond
465}
466
467func (p *PerOperationSamplingStrategies) GetPerOperationStrategies() []*OperationSamplingStrategy {
468 return p.PerOperationStrategies
469}
470var PerOperationSamplingStrategies_DefaultUpperBoundTracesPerSecond_DEFAULT float64
471func (p *PerOperationSamplingStrategies) GetDefaultUpperBoundTracesPerSecond() float64 {
472 if !p.IsSetDefaultUpperBoundTracesPerSecond() {
473 return PerOperationSamplingStrategies_DefaultUpperBoundTracesPerSecond_DEFAULT
474 }
475return *p.DefaultUpperBoundTracesPerSecond
476}
477func (p *PerOperationSamplingStrategies) IsSetDefaultUpperBoundTracesPerSecond() bool {
478 return p.DefaultUpperBoundTracesPerSecond != nil
479}
480
481func (p *PerOperationSamplingStrategies) Read(ctx context.Context, iprot thrift.TProtocol) error {
482 if _, err := iprot.ReadStructBegin(ctx); err != nil {
483 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
484 }
485
486 var issetDefaultSamplingProbability bool = false;
487 var issetDefaultLowerBoundTracesPerSecond bool = false;
488 var issetPerOperationStrategies bool = false;
489
490 for {
491 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
492 if err != nil {
493 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
494 }
495 if fieldTypeId == thrift.STOP { break; }
496 switch fieldId {
497 case 1:
498 if fieldTypeId == thrift.DOUBLE {
499 if err := p.ReadField1(ctx, iprot); err != nil {
500 return err
501 }
502 issetDefaultSamplingProbability = true
503 } else {
504 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
505 return err
506 }
507 }
508 case 2:
509 if fieldTypeId == thrift.DOUBLE {
510 if err := p.ReadField2(ctx, iprot); err != nil {
511 return err
512 }
513 issetDefaultLowerBoundTracesPerSecond = true
514 } else {
515 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
516 return err
517 }
518 }
519 case 3:
520 if fieldTypeId == thrift.LIST {
521 if err := p.ReadField3(ctx, iprot); err != nil {
522 return err
523 }
524 issetPerOperationStrategies = true
525 } else {
526 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
527 return err
528 }
529 }
530 case 4:
531 if fieldTypeId == thrift.DOUBLE {
532 if err := p.ReadField4(ctx, iprot); err != nil {
533 return err
534 }
535 } else {
536 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
537 return err
538 }
539 }
540 default:
541 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
542 return err
543 }
544 }
545 if err := iprot.ReadFieldEnd(ctx); err != nil {
546 return err
547 }
548 }
549 if err := iprot.ReadStructEnd(ctx); err != nil {
550 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
551 }
552 if !issetDefaultSamplingProbability{
553 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field DefaultSamplingProbability is not set"));
554 }
555 if !issetDefaultLowerBoundTracesPerSecond{
556 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field DefaultLowerBoundTracesPerSecond is not set"));
557 }
558 if !issetPerOperationStrategies{
559 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field PerOperationStrategies is not set"));
560 }
561 return nil
562}
563
564func (p *PerOperationSamplingStrategies) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
565 if v, err := iprot.ReadDouble(ctx); err != nil {
566 return thrift.PrependError("error reading field 1: ", err)
567} else {
568 p.DefaultSamplingProbability = v
569}
570 return nil
571}
572
573func (p *PerOperationSamplingStrategies) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
574 if v, err := iprot.ReadDouble(ctx); err != nil {
575 return thrift.PrependError("error reading field 2: ", err)
576} else {
577 p.DefaultLowerBoundTracesPerSecond = v
578}
579 return nil
580}
581
582func (p *PerOperationSamplingStrategies) ReadField3(ctx context.Context, iprot thrift.TProtocol) error {
583 _, size, err := iprot.ReadListBegin(ctx)
584 if err != nil {
585 return thrift.PrependError("error reading list begin: ", err)
586 }
587 tSlice := make([]*OperationSamplingStrategy, 0, size)
588 p.PerOperationStrategies = tSlice
589 for i := 0; i < size; i ++ {
590 _elem0 := &OperationSamplingStrategy{}
591 if err := _elem0.Read(ctx, iprot); err != nil {
592 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem0), err)
593 }
594 p.PerOperationStrategies = append(p.PerOperationStrategies, _elem0)
595 }
596 if err := iprot.ReadListEnd(ctx); err != nil {
597 return thrift.PrependError("error reading list end: ", err)
598 }
599 return nil
600}
601
602func (p *PerOperationSamplingStrategies) ReadField4(ctx context.Context, iprot thrift.TProtocol) error {
603 if v, err := iprot.ReadDouble(ctx); err != nil {
604 return thrift.PrependError("error reading field 4: ", err)
605} else {
606 p.DefaultUpperBoundTracesPerSecond = &v
607}
608 return nil
609}
610
611func (p *PerOperationSamplingStrategies) Write(ctx context.Context, oprot thrift.TProtocol) error {
612 if err := oprot.WriteStructBegin(ctx, "PerOperationSamplingStrategies"); err != nil {
613 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
614 if p != nil {
615 if err := p.writeField1(ctx, oprot); err != nil { return err }
616 if err := p.writeField2(ctx, oprot); err != nil { return err }
617 if err := p.writeField3(ctx, oprot); err != nil { return err }
618 if err := p.writeField4(ctx, oprot); err != nil { return err }
619 }
620 if err := oprot.WriteFieldStop(ctx); err != nil {
621 return thrift.PrependError("write field stop error: ", err) }
622 if err := oprot.WriteStructEnd(ctx); err != nil {
623 return thrift.PrependError("write struct stop error: ", err) }
624 return nil
625}
626
627func (p *PerOperationSamplingStrategies) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
628 if err := oprot.WriteFieldBegin(ctx, "defaultSamplingProbability", thrift.DOUBLE, 1); err != nil {
629 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:defaultSamplingProbability: ", p), err) }
630 if err := oprot.WriteDouble(ctx, float64(p.DefaultSamplingProbability)); err != nil {
631 return thrift.PrependError(fmt.Sprintf("%T.defaultSamplingProbability (1) field write error: ", p), err) }
632 if err := oprot.WriteFieldEnd(ctx); err != nil {
633 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:defaultSamplingProbability: ", p), err) }
634 return err
635}
636
637func (p *PerOperationSamplingStrategies) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
638 if err := oprot.WriteFieldBegin(ctx, "defaultLowerBoundTracesPerSecond", thrift.DOUBLE, 2); err != nil {
639 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:defaultLowerBoundTracesPerSecond: ", p), err) }
640 if err := oprot.WriteDouble(ctx, float64(p.DefaultLowerBoundTracesPerSecond)); err != nil {
641 return thrift.PrependError(fmt.Sprintf("%T.defaultLowerBoundTracesPerSecond (2) field write error: ", p), err) }
642 if err := oprot.WriteFieldEnd(ctx); err != nil {
643 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:defaultLowerBoundTracesPerSecond: ", p), err) }
644 return err
645}
646
647func (p *PerOperationSamplingStrategies) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) {
648 if err := oprot.WriteFieldBegin(ctx, "perOperationStrategies", thrift.LIST, 3); err != nil {
649 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:perOperationStrategies: ", p), err) }
650 if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.PerOperationStrategies)); err != nil {
651 return thrift.PrependError("error writing list begin: ", err)
652 }
653 for _, v := range p.PerOperationStrategies {
654 if err := v.Write(ctx, oprot); err != nil {
655 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err)
656 }
657 }
658 if err := oprot.WriteListEnd(ctx); err != nil {
659 return thrift.PrependError("error writing list end: ", err)
660 }
661 if err := oprot.WriteFieldEnd(ctx); err != nil {
662 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:perOperationStrategies: ", p), err) }
663 return err
664}
665
666func (p *PerOperationSamplingStrategies) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) {
667 if p.IsSetDefaultUpperBoundTracesPerSecond() {
668 if err := oprot.WriteFieldBegin(ctx, "defaultUpperBoundTracesPerSecond", thrift.DOUBLE, 4); err != nil {
669 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:defaultUpperBoundTracesPerSecond: ", p), err) }
670 if err := oprot.WriteDouble(ctx, float64(*p.DefaultUpperBoundTracesPerSecond)); err != nil {
671 return thrift.PrependError(fmt.Sprintf("%T.defaultUpperBoundTracesPerSecond (4) field write error: ", p), err) }
672 if err := oprot.WriteFieldEnd(ctx); err != nil {
673 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:defaultUpperBoundTracesPerSecond: ", p), err) }
674 }
675 return err
676}
677
678func (p *PerOperationSamplingStrategies) Equals(other *PerOperationSamplingStrategies) bool {
679 if p == other {
680 return true
681 } else if p == nil || other == nil {
682 return false
683 }
684 if p.DefaultSamplingProbability != other.DefaultSamplingProbability { return false }
685 if p.DefaultLowerBoundTracesPerSecond != other.DefaultLowerBoundTracesPerSecond { return false }
686 if len(p.PerOperationStrategies) != len(other.PerOperationStrategies) { return false }
687 for i, _tgt := range p.PerOperationStrategies {
688 _src1 := other.PerOperationStrategies[i]
689 if !_tgt.Equals(_src1) { return false }
690 }
691 if p.DefaultUpperBoundTracesPerSecond != other.DefaultUpperBoundTracesPerSecond {
692 if p.DefaultUpperBoundTracesPerSecond == nil || other.DefaultUpperBoundTracesPerSecond == nil {
693 return false
694 }
695 if (*p.DefaultUpperBoundTracesPerSecond) != (*other.DefaultUpperBoundTracesPerSecond) { return false }
696 }
697 return true
698}
699
700func (p *PerOperationSamplingStrategies) String() string {
701 if p == nil {
702 return "<nil>"
703 }
704 return fmt.Sprintf("PerOperationSamplingStrategies(%+v)", *p)
705}
706
707// Attributes:
708// - StrategyType
709// - ProbabilisticSampling
710// - RateLimitingSampling
711// - OperationSampling
712type SamplingStrategyResponse struct {
713 StrategyType SamplingStrategyType `thrift:"strategyType,1,required" db:"strategyType" json:"strategyType"`
714 ProbabilisticSampling *ProbabilisticSamplingStrategy `thrift:"probabilisticSampling,2" db:"probabilisticSampling" json:"probabilisticSampling,omitempty"`
715 RateLimitingSampling *RateLimitingSamplingStrategy `thrift:"rateLimitingSampling,3" db:"rateLimitingSampling" json:"rateLimitingSampling,omitempty"`
716 OperationSampling *PerOperationSamplingStrategies `thrift:"operationSampling,4" db:"operationSampling" json:"operationSampling,omitempty"`
717}
718
719func NewSamplingStrategyResponse() *SamplingStrategyResponse {
720 return &SamplingStrategyResponse{}
721}
722
723
724func (p *SamplingStrategyResponse) GetStrategyType() SamplingStrategyType {
725 return p.StrategyType
726}
727var SamplingStrategyResponse_ProbabilisticSampling_DEFAULT *ProbabilisticSamplingStrategy
728func (p *SamplingStrategyResponse) GetProbabilisticSampling() *ProbabilisticSamplingStrategy {
729 if !p.IsSetProbabilisticSampling() {
730 return SamplingStrategyResponse_ProbabilisticSampling_DEFAULT
731 }
732return p.ProbabilisticSampling
733}
734var SamplingStrategyResponse_RateLimitingSampling_DEFAULT *RateLimitingSamplingStrategy
735func (p *SamplingStrategyResponse) GetRateLimitingSampling() *RateLimitingSamplingStrategy {
736 if !p.IsSetRateLimitingSampling() {
737 return SamplingStrategyResponse_RateLimitingSampling_DEFAULT
738 }
739return p.RateLimitingSampling
740}
741var SamplingStrategyResponse_OperationSampling_DEFAULT *PerOperationSamplingStrategies
742func (p *SamplingStrategyResponse) GetOperationSampling() *PerOperationSamplingStrategies {
743 if !p.IsSetOperationSampling() {
744 return SamplingStrategyResponse_OperationSampling_DEFAULT
745 }
746return p.OperationSampling
747}
748func (p *SamplingStrategyResponse) IsSetProbabilisticSampling() bool {
749 return p.ProbabilisticSampling != nil
750}
751
752func (p *SamplingStrategyResponse) IsSetRateLimitingSampling() bool {
753 return p.RateLimitingSampling != nil
754}
755
756func (p *SamplingStrategyResponse) IsSetOperationSampling() bool {
757 return p.OperationSampling != nil
758}
759
760func (p *SamplingStrategyResponse) Read(ctx context.Context, iprot thrift.TProtocol) error {
761 if _, err := iprot.ReadStructBegin(ctx); err != nil {
762 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
763 }
764
765 var issetStrategyType bool = false;
766
767 for {
768 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
769 if err != nil {
770 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
771 }
772 if fieldTypeId == thrift.STOP { break; }
773 switch fieldId {
774 case 1:
775 if fieldTypeId == thrift.I32 {
776 if err := p.ReadField1(ctx, iprot); err != nil {
777 return err
778 }
779 issetStrategyType = true
780 } else {
781 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
782 return err
783 }
784 }
785 case 2:
786 if fieldTypeId == thrift.STRUCT {
787 if err := p.ReadField2(ctx, iprot); err != nil {
788 return err
789 }
790 } else {
791 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
792 return err
793 }
794 }
795 case 3:
796 if fieldTypeId == thrift.STRUCT {
797 if err := p.ReadField3(ctx, iprot); err != nil {
798 return err
799 }
800 } else {
801 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
802 return err
803 }
804 }
805 case 4:
806 if fieldTypeId == thrift.STRUCT {
807 if err := p.ReadField4(ctx, iprot); err != nil {
808 return err
809 }
810 } else {
811 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
812 return err
813 }
814 }
815 default:
816 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
817 return err
818 }
819 }
820 if err := iprot.ReadFieldEnd(ctx); err != nil {
821 return err
822 }
823 }
824 if err := iprot.ReadStructEnd(ctx); err != nil {
825 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
826 }
827 if !issetStrategyType{
828 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field StrategyType is not set"));
829 }
830 return nil
831}
832
833func (p *SamplingStrategyResponse) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
834 if v, err := iprot.ReadI32(ctx); err != nil {
835 return thrift.PrependError("error reading field 1: ", err)
836} else {
837 temp := SamplingStrategyType(v)
838 p.StrategyType = temp
839}
840 return nil
841}
842
843func (p *SamplingStrategyResponse) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
844 p.ProbabilisticSampling = &ProbabilisticSamplingStrategy{}
845 if err := p.ProbabilisticSampling.Read(ctx, iprot); err != nil {
846 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProbabilisticSampling), err)
847 }
848 return nil
849}
850
851func (p *SamplingStrategyResponse) ReadField3(ctx context.Context, iprot thrift.TProtocol) error {
852 p.RateLimitingSampling = &RateLimitingSamplingStrategy{}
853 if err := p.RateLimitingSampling.Read(ctx, iprot); err != nil {
854 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.RateLimitingSampling), err)
855 }
856 return nil
857}
858
859func (p *SamplingStrategyResponse) ReadField4(ctx context.Context, iprot thrift.TProtocol) error {
860 p.OperationSampling = &PerOperationSamplingStrategies{}
861 if err := p.OperationSampling.Read(ctx, iprot); err != nil {
862 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OperationSampling), err)
863 }
864 return nil
865}
866
867func (p *SamplingStrategyResponse) Write(ctx context.Context, oprot thrift.TProtocol) error {
868 if err := oprot.WriteStructBegin(ctx, "SamplingStrategyResponse"); err != nil {
869 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
870 if p != nil {
871 if err := p.writeField1(ctx, oprot); err != nil { return err }
872 if err := p.writeField2(ctx, oprot); err != nil { return err }
873 if err := p.writeField3(ctx, oprot); err != nil { return err }
874 if err := p.writeField4(ctx, oprot); err != nil { return err }
875 }
876 if err := oprot.WriteFieldStop(ctx); err != nil {
877 return thrift.PrependError("write field stop error: ", err) }
878 if err := oprot.WriteStructEnd(ctx); err != nil {
879 return thrift.PrependError("write struct stop error: ", err) }
880 return nil
881}
882
883func (p *SamplingStrategyResponse) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
884 if err := oprot.WriteFieldBegin(ctx, "strategyType", thrift.I32, 1); err != nil {
885 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:strategyType: ", p), err) }
886 if err := oprot.WriteI32(ctx, int32(p.StrategyType)); err != nil {
887 return thrift.PrependError(fmt.Sprintf("%T.strategyType (1) field write error: ", p), err) }
888 if err := oprot.WriteFieldEnd(ctx); err != nil {
889 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:strategyType: ", p), err) }
890 return err
891}
892
893func (p *SamplingStrategyResponse) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
894 if p.IsSetProbabilisticSampling() {
895 if err := oprot.WriteFieldBegin(ctx, "probabilisticSampling", thrift.STRUCT, 2); err != nil {
896 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:probabilisticSampling: ", p), err) }
897 if err := p.ProbabilisticSampling.Write(ctx, oprot); err != nil {
898 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProbabilisticSampling), err)
899 }
900 if err := oprot.WriteFieldEnd(ctx); err != nil {
901 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:probabilisticSampling: ", p), err) }
902 }
903 return err
904}
905
906func (p *SamplingStrategyResponse) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) {
907 if p.IsSetRateLimitingSampling() {
908 if err := oprot.WriteFieldBegin(ctx, "rateLimitingSampling", thrift.STRUCT, 3); err != nil {
909 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:rateLimitingSampling: ", p), err) }
910 if err := p.RateLimitingSampling.Write(ctx, oprot); err != nil {
911 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.RateLimitingSampling), err)
912 }
913 if err := oprot.WriteFieldEnd(ctx); err != nil {
914 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:rateLimitingSampling: ", p), err) }
915 }
916 return err
917}
918
919func (p *SamplingStrategyResponse) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) {
920 if p.IsSetOperationSampling() {
921 if err := oprot.WriteFieldBegin(ctx, "operationSampling", thrift.STRUCT, 4); err != nil {
922 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:operationSampling: ", p), err) }
923 if err := p.OperationSampling.Write(ctx, oprot); err != nil {
924 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OperationSampling), err)
925 }
926 if err := oprot.WriteFieldEnd(ctx); err != nil {
927 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:operationSampling: ", p), err) }
928 }
929 return err
930}
931
932func (p *SamplingStrategyResponse) Equals(other *SamplingStrategyResponse) bool {
933 if p == other {
934 return true
935 } else if p == nil || other == nil {
936 return false
937 }
938 if p.StrategyType != other.StrategyType { return false }
939 if !p.ProbabilisticSampling.Equals(other.ProbabilisticSampling) { return false }
940 if !p.RateLimitingSampling.Equals(other.RateLimitingSampling) { return false }
941 if !p.OperationSampling.Equals(other.OperationSampling) { return false }
942 return true
943}
944
945func (p *SamplingStrategyResponse) String() string {
946 if p == nil {
947 return "<nil>"
948 }
949 return fmt.Sprintf("SamplingStrategyResponse(%+v)", *p)
950}
951
952type SamplingManager interface {
953 // Parameters:
954 // - ServiceName
955 GetSamplingStrategy(ctx context.Context, serviceName string) (_r *SamplingStrategyResponse, _err error)
956}
957
958type SamplingManagerClient struct {
959 c thrift.TClient
960 meta thrift.ResponseMeta
961}
962
963func NewSamplingManagerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *SamplingManagerClient {
964 return &SamplingManagerClient{
965 c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),
966 }
967}
968
969func NewSamplingManagerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *SamplingManagerClient {
970 return &SamplingManagerClient{
971 c: thrift.NewTStandardClient(iprot, oprot),
972 }
973}
974
975func NewSamplingManagerClient(c thrift.TClient) *SamplingManagerClient {
976 return &SamplingManagerClient{
977 c: c,
978 }
979}
980
981func (p *SamplingManagerClient) Client_() thrift.TClient {
982 return p.c
983}
984
985func (p *SamplingManagerClient) LastResponseMeta_() thrift.ResponseMeta {
986 return p.meta
987}
988
989func (p *SamplingManagerClient) SetLastResponseMeta_(meta thrift.ResponseMeta) {
990 p.meta = meta
991}
992
993// Parameters:
994// - ServiceName
995func (p *SamplingManagerClient) GetSamplingStrategy(ctx context.Context, serviceName string) (_r *SamplingStrategyResponse, _err error) {
996 var _args2 SamplingManagerGetSamplingStrategyArgs
997 _args2.ServiceName = serviceName
998 var _result4 SamplingManagerGetSamplingStrategyResult
999 var _meta3 thrift.ResponseMeta
1000 _meta3, _err = p.Client_().Call(ctx, "getSamplingStrategy", &_args2, &_result4)
1001 p.SetLastResponseMeta_(_meta3)
1002 if _err != nil {
1003 return
1004 }
1005 return _result4.GetSuccess(), nil
1006}
1007
1008type SamplingManagerProcessor struct {
1009 processorMap map[string]thrift.TProcessorFunction
1010 handler SamplingManager
1011}
1012
1013func (p *SamplingManagerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
1014 p.processorMap[key] = processor
1015}
1016
1017func (p *SamplingManagerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
1018 processor, ok = p.processorMap[key]
1019 return processor, ok
1020}
1021
1022func (p *SamplingManagerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
1023 return p.processorMap
1024}
1025
1026func NewSamplingManagerProcessor(handler SamplingManager) *SamplingManagerProcessor {
1027
1028 self5 := &SamplingManagerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}
1029 self5.processorMap["getSamplingStrategy"] = &samplingManagerProcessorGetSamplingStrategy{handler:handler}
1030return self5
1031}
1032
1033func (p *SamplingManagerProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
1034 name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)
1035 if err2 != nil { return false, thrift.WrapTException(err2) }
1036 if processor, ok := p.GetProcessorFunction(name); ok {
1037 return processor.Process(ctx, seqId, iprot, oprot)
1038 }
1039 iprot.Skip(ctx, thrift.STRUCT)
1040 iprot.ReadMessageEnd(ctx)
1041 x6 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name)
1042 oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)
1043 x6.Write(ctx, oprot)
1044 oprot.WriteMessageEnd(ctx)
1045 oprot.Flush(ctx)
1046 return false, x6
1047
1048}
1049
1050type samplingManagerProcessorGetSamplingStrategy struct {
1051 handler SamplingManager
1052}
1053
1054func (p *samplingManagerProcessorGetSamplingStrategy) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
1055 args := SamplingManagerGetSamplingStrategyArgs{}
1056 var err2 error
1057 if err2 = args.Read(ctx, iprot); err2 != nil {
1058 iprot.ReadMessageEnd(ctx)
1059 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error())
1060 oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.EXCEPTION, seqId)
1061 x.Write(ctx, oprot)
1062 oprot.WriteMessageEnd(ctx)
1063 oprot.Flush(ctx)
1064 return false, thrift.WrapTException(err2)
1065 }
1066 iprot.ReadMessageEnd(ctx)
1067
1068 tickerCancel := func() {}
1069 // Start a goroutine to do server side connectivity check.
1070 if thrift.ServerConnectivityCheckInterval > 0 {
1071 var cancel context.CancelFunc
1072 ctx, cancel = context.WithCancel(ctx)
1073 defer cancel()
1074 var tickerCtx context.Context
1075 tickerCtx, tickerCancel = context.WithCancel(context.Background())
1076 defer tickerCancel()
1077 go func(ctx context.Context, cancel context.CancelFunc) {
1078 ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)
1079 defer ticker.Stop()
1080 for {
1081 select {
1082 case <-ctx.Done():
1083 return
1084 case <-ticker.C:
1085 if !iprot.Transport().IsOpen() {
1086 cancel()
1087 return
1088 }
1089 }
1090 }
1091 }(tickerCtx, cancel)
1092 }
1093
1094 result := SamplingManagerGetSamplingStrategyResult{}
1095 var retval *SamplingStrategyResponse
1096 if retval, err2 = p.handler.GetSamplingStrategy(ctx, args.ServiceName); err2 != nil {
1097 tickerCancel()
1098 if err2 == thrift.ErrAbandonRequest {
1099 return false, thrift.WrapTException(err2)
1100 }
1101 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getSamplingStrategy: " + err2.Error())
1102 oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.EXCEPTION, seqId)
1103 x.Write(ctx, oprot)
1104 oprot.WriteMessageEnd(ctx)
1105 oprot.Flush(ctx)
1106 return true, thrift.WrapTException(err2)
1107 } else {
1108 result.Success = retval
1109 }
1110 tickerCancel()
1111 if err2 = oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.REPLY, seqId); err2 != nil {
1112 err = thrift.WrapTException(err2)
1113 }
1114 if err2 = result.Write(ctx, oprot); err == nil && err2 != nil {
1115 err = thrift.WrapTException(err2)
1116 }
1117 if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil {
1118 err = thrift.WrapTException(err2)
1119 }
1120 if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
1121 err = thrift.WrapTException(err2)
1122 }
1123 if err != nil {
1124 return
1125 }
1126 return true, err
1127}
1128
1129
1130// HELPER FUNCTIONS AND STRUCTURES
1131
1132// Attributes:
1133// - ServiceName
1134type SamplingManagerGetSamplingStrategyArgs struct {
1135 ServiceName string `thrift:"serviceName,1" db:"serviceName" json:"serviceName"`
1136}
1137
1138func NewSamplingManagerGetSamplingStrategyArgs() *SamplingManagerGetSamplingStrategyArgs {
1139 return &SamplingManagerGetSamplingStrategyArgs{}
1140}
1141
1142
1143func (p *SamplingManagerGetSamplingStrategyArgs) GetServiceName() string {
1144 return p.ServiceName
1145}
1146func (p *SamplingManagerGetSamplingStrategyArgs) Read(ctx context.Context, iprot thrift.TProtocol) error {
1147 if _, err := iprot.ReadStructBegin(ctx); err != nil {
1148 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
1149 }
1150
1151
1152 for {
1153 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
1154 if err != nil {
1155 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
1156 }
1157 if fieldTypeId == thrift.STOP { break; }
1158 switch fieldId {
1159 case 1:
1160 if fieldTypeId == thrift.STRING {
1161 if err := p.ReadField1(ctx, iprot); err != nil {
1162 return err
1163 }
1164 } else {
1165 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
1166 return err
1167 }
1168 }
1169 default:
1170 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
1171 return err
1172 }
1173 }
1174 if err := iprot.ReadFieldEnd(ctx); err != nil {
1175 return err
1176 }
1177 }
1178 if err := iprot.ReadStructEnd(ctx); err != nil {
1179 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
1180 }
1181 return nil
1182}
1183
1184func (p *SamplingManagerGetSamplingStrategyArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
1185 if v, err := iprot.ReadString(ctx); err != nil {
1186 return thrift.PrependError("error reading field 1: ", err)
1187} else {
1188 p.ServiceName = v
1189}
1190 return nil
1191}
1192
1193func (p *SamplingManagerGetSamplingStrategyArgs) Write(ctx context.Context, oprot thrift.TProtocol) error {
1194 if err := oprot.WriteStructBegin(ctx, "getSamplingStrategy_args"); err != nil {
1195 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
1196 if p != nil {
1197 if err := p.writeField1(ctx, oprot); err != nil { return err }
1198 }
1199 if err := oprot.WriteFieldStop(ctx); err != nil {
1200 return thrift.PrependError("write field stop error: ", err) }
1201 if err := oprot.WriteStructEnd(ctx); err != nil {
1202 return thrift.PrependError("write struct stop error: ", err) }
1203 return nil
1204}
1205
1206func (p *SamplingManagerGetSamplingStrategyArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
1207 if err := oprot.WriteFieldBegin(ctx, "serviceName", thrift.STRING, 1); err != nil {
1208 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:serviceName: ", p), err) }
1209 if err := oprot.WriteString(ctx, string(p.ServiceName)); err != nil {
1210 return thrift.PrependError(fmt.Sprintf("%T.serviceName (1) field write error: ", p), err) }
1211 if err := oprot.WriteFieldEnd(ctx); err != nil {
1212 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:serviceName: ", p), err) }
1213 return err
1214}
1215
1216func (p *SamplingManagerGetSamplingStrategyArgs) String() string {
1217 if p == nil {
1218 return "<nil>"
1219 }
1220 return fmt.Sprintf("SamplingManagerGetSamplingStrategyArgs(%+v)", *p)
1221}
1222
1223// Attributes:
1224// - Success
1225type SamplingManagerGetSamplingStrategyResult struct {
1226 Success *SamplingStrategyResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
1227}
1228
1229func NewSamplingManagerGetSamplingStrategyResult() *SamplingManagerGetSamplingStrategyResult {
1230 return &SamplingManagerGetSamplingStrategyResult{}
1231}
1232
1233var SamplingManagerGetSamplingStrategyResult_Success_DEFAULT *SamplingStrategyResponse
1234func (p *SamplingManagerGetSamplingStrategyResult) GetSuccess() *SamplingStrategyResponse {
1235 if !p.IsSetSuccess() {
1236 return SamplingManagerGetSamplingStrategyResult_Success_DEFAULT
1237 }
1238return p.Success
1239}
1240func (p *SamplingManagerGetSamplingStrategyResult) IsSetSuccess() bool {
1241 return p.Success != nil
1242}
1243
1244func (p *SamplingManagerGetSamplingStrategyResult) Read(ctx context.Context, iprot thrift.TProtocol) error {
1245 if _, err := iprot.ReadStructBegin(ctx); err != nil {
1246 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
1247 }
1248
1249
1250 for {
1251 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
1252 if err != nil {
1253 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
1254 }
1255 if fieldTypeId == thrift.STOP { break; }
1256 switch fieldId {
1257 case 0:
1258 if fieldTypeId == thrift.STRUCT {
1259 if err := p.ReadField0(ctx, iprot); err != nil {
1260 return err
1261 }
1262 } else {
1263 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
1264 return err
1265 }
1266 }
1267 default:
1268 if err := iprot.Skip(ctx, fieldTypeId); err != nil {
1269 return err
1270 }
1271 }
1272 if err := iprot.ReadFieldEnd(ctx); err != nil {
1273 return err
1274 }
1275 }
1276 if err := iprot.ReadStructEnd(ctx); err != nil {
1277 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
1278 }
1279 return nil
1280}
1281
1282func (p *SamplingManagerGetSamplingStrategyResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error {
1283 p.Success = &SamplingStrategyResponse{}
1284 if err := p.Success.Read(ctx, iprot); err != nil {
1285 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
1286 }
1287 return nil
1288}
1289
1290func (p *SamplingManagerGetSamplingStrategyResult) Write(ctx context.Context, oprot thrift.TProtocol) error {
1291 if err := oprot.WriteStructBegin(ctx, "getSamplingStrategy_result"); err != nil {
1292 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
1293 if p != nil {
1294 if err := p.writeField0(ctx, oprot); err != nil { return err }
1295 }
1296 if err := oprot.WriteFieldStop(ctx); err != nil {
1297 return thrift.PrependError("write field stop error: ", err) }
1298 if err := oprot.WriteStructEnd(ctx); err != nil {
1299 return thrift.PrependError("write struct stop error: ", err) }
1300 return nil
1301}
1302
1303func (p *SamplingManagerGetSamplingStrategyResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) {
1304 if p.IsSetSuccess() {
1305 if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil {
1306 return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
1307 if err := p.Success.Write(ctx, oprot); err != nil {
1308 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
1309 }
1310 if err := oprot.WriteFieldEnd(ctx); err != nil {
1311 return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
1312 }
1313 return err
1314}
1315
1316func (p *SamplingManagerGetSamplingStrategyResult) String() string {
1317 if p == nil {
1318 return "<nil>"
1319 }
1320 return fmt.Sprintf("SamplingManagerGetSamplingStrategyResult(%+v)", *p)
1321}
1322
1323