123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323 |
- // Code generated by Thrift Compiler (0.14.1). DO NOT EDIT.
- package sampling
- import(
- "bytes"
- "context"
- "database/sql/driver"
- "errors"
- "fmt"
- "time"
- "github.com/uber/jaeger-client-go/thrift"
- )
- // (needed to ensure safety because of naive import list construction.)
- var _ = thrift.ZERO
- var _ = fmt.Printf
- var _ = context.Background
- var _ = time.Now
- var _ = bytes.Equal
- type SamplingStrategyType int64
- const (
- SamplingStrategyType_PROBABILISTIC SamplingStrategyType = 0
- SamplingStrategyType_RATE_LIMITING SamplingStrategyType = 1
- )
- func (p SamplingStrategyType) String() string {
- switch p {
- case SamplingStrategyType_PROBABILISTIC: return "PROBABILISTIC"
- case SamplingStrategyType_RATE_LIMITING: return "RATE_LIMITING"
- }
- return "<UNSET>"
- }
- func SamplingStrategyTypeFromString(s string) (SamplingStrategyType, error) {
- switch s {
- case "PROBABILISTIC": return SamplingStrategyType_PROBABILISTIC, nil
- case "RATE_LIMITING": return SamplingStrategyType_RATE_LIMITING, nil
- }
- return SamplingStrategyType(0), fmt.Errorf("not a valid SamplingStrategyType string")
- }
- func SamplingStrategyTypePtr(v SamplingStrategyType) *SamplingStrategyType { return &v }
- func (p SamplingStrategyType) MarshalText() ([]byte, error) {
- return []byte(p.String()), nil
- }
- func (p *SamplingStrategyType) UnmarshalText(text []byte) error {
- q, err := SamplingStrategyTypeFromString(string(text))
- if (err != nil) {
- return err
- }
- *p = q
- return nil
- }
- func (p *SamplingStrategyType) Scan(value interface{}) error {
- v, ok := value.(int64)
- if !ok {
- return errors.New("Scan value is not int64")
- }
- *p = SamplingStrategyType(v)
- return nil
- }
- func (p * SamplingStrategyType) Value() (driver.Value, error) {
- if p == nil {
- return nil, nil
- }
- return int64(*p), nil
- }
- // Attributes:
- // - SamplingRate
- type ProbabilisticSamplingStrategy struct {
- SamplingRate float64 `thrift:"samplingRate,1,required" db:"samplingRate" json:"samplingRate"`
- }
- func NewProbabilisticSamplingStrategy() *ProbabilisticSamplingStrategy {
- return &ProbabilisticSamplingStrategy{}
- }
- func (p *ProbabilisticSamplingStrategy) GetSamplingRate() float64 {
- return p.SamplingRate
- }
- func (p *ProbabilisticSamplingStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error {
- if _, err := iprot.ReadStructBegin(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
- }
- var issetSamplingRate bool = false;
- for {
- _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
- if err != nil {
- return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
- }
- if fieldTypeId == thrift.STOP { break; }
- switch fieldId {
- case 1:
- if fieldTypeId == thrift.DOUBLE {
- if err := p.ReadField1(ctx, iprot); err != nil {
- return err
- }
- issetSamplingRate = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- default:
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- if err := iprot.ReadFieldEnd(ctx); err != nil {
- return err
- }
- }
- if err := iprot.ReadStructEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
- }
- if !issetSamplingRate{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field SamplingRate is not set"));
- }
- return nil
- }
- func (p *ProbabilisticSamplingStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadDouble(ctx); err != nil {
- return thrift.PrependError("error reading field 1: ", err)
- } else {
- p.SamplingRate = v
- }
- return nil
- }
- func (p *ProbabilisticSamplingStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error {
- if err := oprot.WriteStructBegin(ctx, "ProbabilisticSamplingStrategy"); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
- if p != nil {
- if err := p.writeField1(ctx, oprot); err != nil { return err }
- }
- if err := oprot.WriteFieldStop(ctx); err != nil {
- return thrift.PrependError("write field stop error: ", err) }
- if err := oprot.WriteStructEnd(ctx); err != nil {
- return thrift.PrependError("write struct stop error: ", err) }
- return nil
- }
- func (p *ProbabilisticSamplingStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "samplingRate", thrift.DOUBLE, 1); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:samplingRate: ", p), err) }
- if err := oprot.WriteDouble(ctx, float64(p.SamplingRate)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.samplingRate (1) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 1:samplingRate: ", p), err) }
- return err
- }
- func (p *ProbabilisticSamplingStrategy) Equals(other *ProbabilisticSamplingStrategy) bool {
- if p == other {
- return true
- } else if p == nil || other == nil {
- return false
- }
- if p.SamplingRate != other.SamplingRate { return false }
- return true
- }
- func (p *ProbabilisticSamplingStrategy) String() string {
- if p == nil {
- return "<nil>"
- }
- return fmt.Sprintf("ProbabilisticSamplingStrategy(%+v)", *p)
- }
- // Attributes:
- // - MaxTracesPerSecond
- type RateLimitingSamplingStrategy struct {
- MaxTracesPerSecond int16 `thrift:"maxTracesPerSecond,1,required" db:"maxTracesPerSecond" json:"maxTracesPerSecond"`
- }
- func NewRateLimitingSamplingStrategy() *RateLimitingSamplingStrategy {
- return &RateLimitingSamplingStrategy{}
- }
- func (p *RateLimitingSamplingStrategy) GetMaxTracesPerSecond() int16 {
- return p.MaxTracesPerSecond
- }
- func (p *RateLimitingSamplingStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error {
- if _, err := iprot.ReadStructBegin(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
- }
- var issetMaxTracesPerSecond bool = false;
- for {
- _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
- if err != nil {
- return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
- }
- if fieldTypeId == thrift.STOP { break; }
- switch fieldId {
- case 1:
- if fieldTypeId == thrift.I16 {
- if err := p.ReadField1(ctx, iprot); err != nil {
- return err
- }
- issetMaxTracesPerSecond = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- default:
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- if err := iprot.ReadFieldEnd(ctx); err != nil {
- return err
- }
- }
- if err := iprot.ReadStructEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
- }
- if !issetMaxTracesPerSecond{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field MaxTracesPerSecond is not set"));
- }
- return nil
- }
- func (p *RateLimitingSamplingStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadI16(ctx); err != nil {
- return thrift.PrependError("error reading field 1: ", err)
- } else {
- p.MaxTracesPerSecond = v
- }
- return nil
- }
- func (p *RateLimitingSamplingStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error {
- if err := oprot.WriteStructBegin(ctx, "RateLimitingSamplingStrategy"); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
- if p != nil {
- if err := p.writeField1(ctx, oprot); err != nil { return err }
- }
- if err := oprot.WriteFieldStop(ctx); err != nil {
- return thrift.PrependError("write field stop error: ", err) }
- if err := oprot.WriteStructEnd(ctx); err != nil {
- return thrift.PrependError("write struct stop error: ", err) }
- return nil
- }
- func (p *RateLimitingSamplingStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "maxTracesPerSecond", thrift.I16, 1); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:maxTracesPerSecond: ", p), err) }
- if err := oprot.WriteI16(ctx, int16(p.MaxTracesPerSecond)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.maxTracesPerSecond (1) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 1:maxTracesPerSecond: ", p), err) }
- return err
- }
- func (p *RateLimitingSamplingStrategy) Equals(other *RateLimitingSamplingStrategy) bool {
- if p == other {
- return true
- } else if p == nil || other == nil {
- return false
- }
- if p.MaxTracesPerSecond != other.MaxTracesPerSecond { return false }
- return true
- }
- func (p *RateLimitingSamplingStrategy) String() string {
- if p == nil {
- return "<nil>"
- }
- return fmt.Sprintf("RateLimitingSamplingStrategy(%+v)", *p)
- }
- // Attributes:
- // - Operation
- // - ProbabilisticSampling
- type OperationSamplingStrategy struct {
- Operation string `thrift:"operation,1,required" db:"operation" json:"operation"`
- ProbabilisticSampling *ProbabilisticSamplingStrategy `thrift:"probabilisticSampling,2,required" db:"probabilisticSampling" json:"probabilisticSampling"`
- }
- func NewOperationSamplingStrategy() *OperationSamplingStrategy {
- return &OperationSamplingStrategy{}
- }
- func (p *OperationSamplingStrategy) GetOperation() string {
- return p.Operation
- }
- var OperationSamplingStrategy_ProbabilisticSampling_DEFAULT *ProbabilisticSamplingStrategy
- func (p *OperationSamplingStrategy) GetProbabilisticSampling() *ProbabilisticSamplingStrategy {
- if !p.IsSetProbabilisticSampling() {
- return OperationSamplingStrategy_ProbabilisticSampling_DEFAULT
- }
- return p.ProbabilisticSampling
- }
- func (p *OperationSamplingStrategy) IsSetProbabilisticSampling() bool {
- return p.ProbabilisticSampling != nil
- }
- func (p *OperationSamplingStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error {
- if _, err := iprot.ReadStructBegin(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
- }
- var issetOperation bool = false;
- var issetProbabilisticSampling bool = false;
- for {
- _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
- if err != nil {
- return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
- }
- if fieldTypeId == thrift.STOP { break; }
- switch fieldId {
- case 1:
- if fieldTypeId == thrift.STRING {
- if err := p.ReadField1(ctx, iprot); err != nil {
- return err
- }
- issetOperation = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- case 2:
- if fieldTypeId == thrift.STRUCT {
- if err := p.ReadField2(ctx, iprot); err != nil {
- return err
- }
- issetProbabilisticSampling = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- default:
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- if err := iprot.ReadFieldEnd(ctx); err != nil {
- return err
- }
- }
- if err := iprot.ReadStructEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
- }
- if !issetOperation{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Operation is not set"));
- }
- if !issetProbabilisticSampling{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field ProbabilisticSampling is not set"));
- }
- return nil
- }
- func (p *OperationSamplingStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadString(ctx); err != nil {
- return thrift.PrependError("error reading field 1: ", err)
- } else {
- p.Operation = v
- }
- return nil
- }
- func (p *OperationSamplingStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
- p.ProbabilisticSampling = &ProbabilisticSamplingStrategy{}
- if err := p.ProbabilisticSampling.Read(ctx, iprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProbabilisticSampling), err)
- }
- return nil
- }
- func (p *OperationSamplingStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error {
- if err := oprot.WriteStructBegin(ctx, "OperationSamplingStrategy"); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
- if p != nil {
- if err := p.writeField1(ctx, oprot); err != nil { return err }
- if err := p.writeField2(ctx, oprot); err != nil { return err }
- }
- if err := oprot.WriteFieldStop(ctx); err != nil {
- return thrift.PrependError("write field stop error: ", err) }
- if err := oprot.WriteStructEnd(ctx); err != nil {
- return thrift.PrependError("write struct stop error: ", err) }
- return nil
- }
- func (p *OperationSamplingStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "operation", thrift.STRING, 1); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:operation: ", p), err) }
- if err := oprot.WriteString(ctx, string(p.Operation)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.operation (1) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 1:operation: ", p), err) }
- return err
- }
- func (p *OperationSamplingStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "probabilisticSampling", thrift.STRUCT, 2); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:probabilisticSampling: ", p), err) }
- if err := p.ProbabilisticSampling.Write(ctx, oprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProbabilisticSampling), err)
- }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 2:probabilisticSampling: ", p), err) }
- return err
- }
- func (p *OperationSamplingStrategy) Equals(other *OperationSamplingStrategy) bool {
- if p == other {
- return true
- } else if p == nil || other == nil {
- return false
- }
- if p.Operation != other.Operation { return false }
- if !p.ProbabilisticSampling.Equals(other.ProbabilisticSampling) { return false }
- return true
- }
- func (p *OperationSamplingStrategy) String() string {
- if p == nil {
- return "<nil>"
- }
- return fmt.Sprintf("OperationSamplingStrategy(%+v)", *p)
- }
- // Attributes:
- // - DefaultSamplingProbability
- // - DefaultLowerBoundTracesPerSecond
- // - PerOperationStrategies
- // - DefaultUpperBoundTracesPerSecond
- type PerOperationSamplingStrategies struct {
- DefaultSamplingProbability float64 `thrift:"defaultSamplingProbability,1,required" db:"defaultSamplingProbability" json:"defaultSamplingProbability"`
- DefaultLowerBoundTracesPerSecond float64 `thrift:"defaultLowerBoundTracesPerSecond,2,required" db:"defaultLowerBoundTracesPerSecond" json:"defaultLowerBoundTracesPerSecond"`
- PerOperationStrategies []*OperationSamplingStrategy `thrift:"perOperationStrategies,3,required" db:"perOperationStrategies" json:"perOperationStrategies"`
- DefaultUpperBoundTracesPerSecond *float64 `thrift:"defaultUpperBoundTracesPerSecond,4" db:"defaultUpperBoundTracesPerSecond" json:"defaultUpperBoundTracesPerSecond,omitempty"`
- }
- func NewPerOperationSamplingStrategies() *PerOperationSamplingStrategies {
- return &PerOperationSamplingStrategies{}
- }
- func (p *PerOperationSamplingStrategies) GetDefaultSamplingProbability() float64 {
- return p.DefaultSamplingProbability
- }
- func (p *PerOperationSamplingStrategies) GetDefaultLowerBoundTracesPerSecond() float64 {
- return p.DefaultLowerBoundTracesPerSecond
- }
- func (p *PerOperationSamplingStrategies) GetPerOperationStrategies() []*OperationSamplingStrategy {
- return p.PerOperationStrategies
- }
- var PerOperationSamplingStrategies_DefaultUpperBoundTracesPerSecond_DEFAULT float64
- func (p *PerOperationSamplingStrategies) GetDefaultUpperBoundTracesPerSecond() float64 {
- if !p.IsSetDefaultUpperBoundTracesPerSecond() {
- return PerOperationSamplingStrategies_DefaultUpperBoundTracesPerSecond_DEFAULT
- }
- return *p.DefaultUpperBoundTracesPerSecond
- }
- func (p *PerOperationSamplingStrategies) IsSetDefaultUpperBoundTracesPerSecond() bool {
- return p.DefaultUpperBoundTracesPerSecond != nil
- }
- func (p *PerOperationSamplingStrategies) Read(ctx context.Context, iprot thrift.TProtocol) error {
- if _, err := iprot.ReadStructBegin(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
- }
- var issetDefaultSamplingProbability bool = false;
- var issetDefaultLowerBoundTracesPerSecond bool = false;
- var issetPerOperationStrategies bool = false;
- for {
- _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
- if err != nil {
- return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
- }
- if fieldTypeId == thrift.STOP { break; }
- switch fieldId {
- case 1:
- if fieldTypeId == thrift.DOUBLE {
- if err := p.ReadField1(ctx, iprot); err != nil {
- return err
- }
- issetDefaultSamplingProbability = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- case 2:
- if fieldTypeId == thrift.DOUBLE {
- if err := p.ReadField2(ctx, iprot); err != nil {
- return err
- }
- issetDefaultLowerBoundTracesPerSecond = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- case 3:
- if fieldTypeId == thrift.LIST {
- if err := p.ReadField3(ctx, iprot); err != nil {
- return err
- }
- issetPerOperationStrategies = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- case 4:
- if fieldTypeId == thrift.DOUBLE {
- if err := p.ReadField4(ctx, iprot); err != nil {
- return err
- }
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- default:
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- if err := iprot.ReadFieldEnd(ctx); err != nil {
- return err
- }
- }
- if err := iprot.ReadStructEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
- }
- if !issetDefaultSamplingProbability{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field DefaultSamplingProbability is not set"));
- }
- if !issetDefaultLowerBoundTracesPerSecond{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field DefaultLowerBoundTracesPerSecond is not set"));
- }
- if !issetPerOperationStrategies{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field PerOperationStrategies is not set"));
- }
- return nil
- }
- func (p *PerOperationSamplingStrategies) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadDouble(ctx); err != nil {
- return thrift.PrependError("error reading field 1: ", err)
- } else {
- p.DefaultSamplingProbability = v
- }
- return nil
- }
- func (p *PerOperationSamplingStrategies) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadDouble(ctx); err != nil {
- return thrift.PrependError("error reading field 2: ", err)
- } else {
- p.DefaultLowerBoundTracesPerSecond = v
- }
- return nil
- }
- func (p *PerOperationSamplingStrategies) ReadField3(ctx context.Context, iprot thrift.TProtocol) error {
- _, size, err := iprot.ReadListBegin(ctx)
- if err != nil {
- return thrift.PrependError("error reading list begin: ", err)
- }
- tSlice := make([]*OperationSamplingStrategy, 0, size)
- p.PerOperationStrategies = tSlice
- for i := 0; i < size; i ++ {
- _elem0 := &OperationSamplingStrategy{}
- if err := _elem0.Read(ctx, iprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem0), err)
- }
- p.PerOperationStrategies = append(p.PerOperationStrategies, _elem0)
- }
- if err := iprot.ReadListEnd(ctx); err != nil {
- return thrift.PrependError("error reading list end: ", err)
- }
- return nil
- }
- func (p *PerOperationSamplingStrategies) ReadField4(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadDouble(ctx); err != nil {
- return thrift.PrependError("error reading field 4: ", err)
- } else {
- p.DefaultUpperBoundTracesPerSecond = &v
- }
- return nil
- }
- func (p *PerOperationSamplingStrategies) Write(ctx context.Context, oprot thrift.TProtocol) error {
- if err := oprot.WriteStructBegin(ctx, "PerOperationSamplingStrategies"); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
- if p != nil {
- if err := p.writeField1(ctx, oprot); err != nil { return err }
- if err := p.writeField2(ctx, oprot); err != nil { return err }
- if err := p.writeField3(ctx, oprot); err != nil { return err }
- if err := p.writeField4(ctx, oprot); err != nil { return err }
- }
- if err := oprot.WriteFieldStop(ctx); err != nil {
- return thrift.PrependError("write field stop error: ", err) }
- if err := oprot.WriteStructEnd(ctx); err != nil {
- return thrift.PrependError("write struct stop error: ", err) }
- return nil
- }
- func (p *PerOperationSamplingStrategies) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "defaultSamplingProbability", thrift.DOUBLE, 1); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:defaultSamplingProbability: ", p), err) }
- if err := oprot.WriteDouble(ctx, float64(p.DefaultSamplingProbability)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.defaultSamplingProbability (1) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 1:defaultSamplingProbability: ", p), err) }
- return err
- }
- func (p *PerOperationSamplingStrategies) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "defaultLowerBoundTracesPerSecond", thrift.DOUBLE, 2); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:defaultLowerBoundTracesPerSecond: ", p), err) }
- if err := oprot.WriteDouble(ctx, float64(p.DefaultLowerBoundTracesPerSecond)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.defaultLowerBoundTracesPerSecond (2) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 2:defaultLowerBoundTracesPerSecond: ", p), err) }
- return err
- }
- func (p *PerOperationSamplingStrategies) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "perOperationStrategies", thrift.LIST, 3); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:perOperationStrategies: ", p), err) }
- if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.PerOperationStrategies)); err != nil {
- return thrift.PrependError("error writing list begin: ", err)
- }
- for _, v := range p.PerOperationStrategies {
- if err := v.Write(ctx, oprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err)
- }
- }
- if err := oprot.WriteListEnd(ctx); err != nil {
- return thrift.PrependError("error writing list end: ", err)
- }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 3:perOperationStrategies: ", p), err) }
- return err
- }
- func (p *PerOperationSamplingStrategies) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if p.IsSetDefaultUpperBoundTracesPerSecond() {
- if err := oprot.WriteFieldBegin(ctx, "defaultUpperBoundTracesPerSecond", thrift.DOUBLE, 4); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:defaultUpperBoundTracesPerSecond: ", p), err) }
- if err := oprot.WriteDouble(ctx, float64(*p.DefaultUpperBoundTracesPerSecond)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.defaultUpperBoundTracesPerSecond (4) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 4:defaultUpperBoundTracesPerSecond: ", p), err) }
- }
- return err
- }
- func (p *PerOperationSamplingStrategies) Equals(other *PerOperationSamplingStrategies) bool {
- if p == other {
- return true
- } else if p == nil || other == nil {
- return false
- }
- if p.DefaultSamplingProbability != other.DefaultSamplingProbability { return false }
- if p.DefaultLowerBoundTracesPerSecond != other.DefaultLowerBoundTracesPerSecond { return false }
- if len(p.PerOperationStrategies) != len(other.PerOperationStrategies) { return false }
- for i, _tgt := range p.PerOperationStrategies {
- _src1 := other.PerOperationStrategies[i]
- if !_tgt.Equals(_src1) { return false }
- }
- if p.DefaultUpperBoundTracesPerSecond != other.DefaultUpperBoundTracesPerSecond {
- if p.DefaultUpperBoundTracesPerSecond == nil || other.DefaultUpperBoundTracesPerSecond == nil {
- return false
- }
- if (*p.DefaultUpperBoundTracesPerSecond) != (*other.DefaultUpperBoundTracesPerSecond) { return false }
- }
- return true
- }
- func (p *PerOperationSamplingStrategies) String() string {
- if p == nil {
- return "<nil>"
- }
- return fmt.Sprintf("PerOperationSamplingStrategies(%+v)", *p)
- }
- // Attributes:
- // - StrategyType
- // - ProbabilisticSampling
- // - RateLimitingSampling
- // - OperationSampling
- type SamplingStrategyResponse struct {
- StrategyType SamplingStrategyType `thrift:"strategyType,1,required" db:"strategyType" json:"strategyType"`
- ProbabilisticSampling *ProbabilisticSamplingStrategy `thrift:"probabilisticSampling,2" db:"probabilisticSampling" json:"probabilisticSampling,omitempty"`
- RateLimitingSampling *RateLimitingSamplingStrategy `thrift:"rateLimitingSampling,3" db:"rateLimitingSampling" json:"rateLimitingSampling,omitempty"`
- OperationSampling *PerOperationSamplingStrategies `thrift:"operationSampling,4" db:"operationSampling" json:"operationSampling,omitempty"`
- }
- func NewSamplingStrategyResponse() *SamplingStrategyResponse {
- return &SamplingStrategyResponse{}
- }
- func (p *SamplingStrategyResponse) GetStrategyType() SamplingStrategyType {
- return p.StrategyType
- }
- var SamplingStrategyResponse_ProbabilisticSampling_DEFAULT *ProbabilisticSamplingStrategy
- func (p *SamplingStrategyResponse) GetProbabilisticSampling() *ProbabilisticSamplingStrategy {
- if !p.IsSetProbabilisticSampling() {
- return SamplingStrategyResponse_ProbabilisticSampling_DEFAULT
- }
- return p.ProbabilisticSampling
- }
- var SamplingStrategyResponse_RateLimitingSampling_DEFAULT *RateLimitingSamplingStrategy
- func (p *SamplingStrategyResponse) GetRateLimitingSampling() *RateLimitingSamplingStrategy {
- if !p.IsSetRateLimitingSampling() {
- return SamplingStrategyResponse_RateLimitingSampling_DEFAULT
- }
- return p.RateLimitingSampling
- }
- var SamplingStrategyResponse_OperationSampling_DEFAULT *PerOperationSamplingStrategies
- func (p *SamplingStrategyResponse) GetOperationSampling() *PerOperationSamplingStrategies {
- if !p.IsSetOperationSampling() {
- return SamplingStrategyResponse_OperationSampling_DEFAULT
- }
- return p.OperationSampling
- }
- func (p *SamplingStrategyResponse) IsSetProbabilisticSampling() bool {
- return p.ProbabilisticSampling != nil
- }
- func (p *SamplingStrategyResponse) IsSetRateLimitingSampling() bool {
- return p.RateLimitingSampling != nil
- }
- func (p *SamplingStrategyResponse) IsSetOperationSampling() bool {
- return p.OperationSampling != nil
- }
- func (p *SamplingStrategyResponse) Read(ctx context.Context, iprot thrift.TProtocol) error {
- if _, err := iprot.ReadStructBegin(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
- }
- var issetStrategyType bool = false;
- for {
- _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
- if err != nil {
- return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
- }
- if fieldTypeId == thrift.STOP { break; }
- switch fieldId {
- case 1:
- if fieldTypeId == thrift.I32 {
- if err := p.ReadField1(ctx, iprot); err != nil {
- return err
- }
- issetStrategyType = true
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- case 2:
- if fieldTypeId == thrift.STRUCT {
- if err := p.ReadField2(ctx, iprot); err != nil {
- return err
- }
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- case 3:
- if fieldTypeId == thrift.STRUCT {
- if err := p.ReadField3(ctx, iprot); err != nil {
- return err
- }
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- case 4:
- if fieldTypeId == thrift.STRUCT {
- if err := p.ReadField4(ctx, iprot); err != nil {
- return err
- }
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- default:
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- if err := iprot.ReadFieldEnd(ctx); err != nil {
- return err
- }
- }
- if err := iprot.ReadStructEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
- }
- if !issetStrategyType{
- return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field StrategyType is not set"));
- }
- return nil
- }
- func (p *SamplingStrategyResponse) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadI32(ctx); err != nil {
- return thrift.PrependError("error reading field 1: ", err)
- } else {
- temp := SamplingStrategyType(v)
- p.StrategyType = temp
- }
- return nil
- }
- func (p *SamplingStrategyResponse) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
- p.ProbabilisticSampling = &ProbabilisticSamplingStrategy{}
- if err := p.ProbabilisticSampling.Read(ctx, iprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProbabilisticSampling), err)
- }
- return nil
- }
- func (p *SamplingStrategyResponse) ReadField3(ctx context.Context, iprot thrift.TProtocol) error {
- p.RateLimitingSampling = &RateLimitingSamplingStrategy{}
- if err := p.RateLimitingSampling.Read(ctx, iprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.RateLimitingSampling), err)
- }
- return nil
- }
- func (p *SamplingStrategyResponse) ReadField4(ctx context.Context, iprot thrift.TProtocol) error {
- p.OperationSampling = &PerOperationSamplingStrategies{}
- if err := p.OperationSampling.Read(ctx, iprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OperationSampling), err)
- }
- return nil
- }
- func (p *SamplingStrategyResponse) Write(ctx context.Context, oprot thrift.TProtocol) error {
- if err := oprot.WriteStructBegin(ctx, "SamplingStrategyResponse"); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
- if p != nil {
- if err := p.writeField1(ctx, oprot); err != nil { return err }
- if err := p.writeField2(ctx, oprot); err != nil { return err }
- if err := p.writeField3(ctx, oprot); err != nil { return err }
- if err := p.writeField4(ctx, oprot); err != nil { return err }
- }
- if err := oprot.WriteFieldStop(ctx); err != nil {
- return thrift.PrependError("write field stop error: ", err) }
- if err := oprot.WriteStructEnd(ctx); err != nil {
- return thrift.PrependError("write struct stop error: ", err) }
- return nil
- }
- func (p *SamplingStrategyResponse) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "strategyType", thrift.I32, 1); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:strategyType: ", p), err) }
- if err := oprot.WriteI32(ctx, int32(p.StrategyType)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.strategyType (1) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 1:strategyType: ", p), err) }
- return err
- }
- func (p *SamplingStrategyResponse) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if p.IsSetProbabilisticSampling() {
- if err := oprot.WriteFieldBegin(ctx, "probabilisticSampling", thrift.STRUCT, 2); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:probabilisticSampling: ", p), err) }
- if err := p.ProbabilisticSampling.Write(ctx, oprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProbabilisticSampling), err)
- }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 2:probabilisticSampling: ", p), err) }
- }
- return err
- }
- func (p *SamplingStrategyResponse) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if p.IsSetRateLimitingSampling() {
- if err := oprot.WriteFieldBegin(ctx, "rateLimitingSampling", thrift.STRUCT, 3); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:rateLimitingSampling: ", p), err) }
- if err := p.RateLimitingSampling.Write(ctx, oprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.RateLimitingSampling), err)
- }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 3:rateLimitingSampling: ", p), err) }
- }
- return err
- }
- func (p *SamplingStrategyResponse) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if p.IsSetOperationSampling() {
- if err := oprot.WriteFieldBegin(ctx, "operationSampling", thrift.STRUCT, 4); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:operationSampling: ", p), err) }
- if err := p.OperationSampling.Write(ctx, oprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OperationSampling), err)
- }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 4:operationSampling: ", p), err) }
- }
- return err
- }
- func (p *SamplingStrategyResponse) Equals(other *SamplingStrategyResponse) bool {
- if p == other {
- return true
- } else if p == nil || other == nil {
- return false
- }
- if p.StrategyType != other.StrategyType { return false }
- if !p.ProbabilisticSampling.Equals(other.ProbabilisticSampling) { return false }
- if !p.RateLimitingSampling.Equals(other.RateLimitingSampling) { return false }
- if !p.OperationSampling.Equals(other.OperationSampling) { return false }
- return true
- }
- func (p *SamplingStrategyResponse) String() string {
- if p == nil {
- return "<nil>"
- }
- return fmt.Sprintf("SamplingStrategyResponse(%+v)", *p)
- }
- type SamplingManager interface {
- // Parameters:
- // - ServiceName
- GetSamplingStrategy(ctx context.Context, serviceName string) (_r *SamplingStrategyResponse, _err error)
- }
- type SamplingManagerClient struct {
- c thrift.TClient
- meta thrift.ResponseMeta
- }
- func NewSamplingManagerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *SamplingManagerClient {
- return &SamplingManagerClient{
- c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),
- }
- }
- func NewSamplingManagerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *SamplingManagerClient {
- return &SamplingManagerClient{
- c: thrift.NewTStandardClient(iprot, oprot),
- }
- }
- func NewSamplingManagerClient(c thrift.TClient) *SamplingManagerClient {
- return &SamplingManagerClient{
- c: c,
- }
- }
- func (p *SamplingManagerClient) Client_() thrift.TClient {
- return p.c
- }
- func (p *SamplingManagerClient) LastResponseMeta_() thrift.ResponseMeta {
- return p.meta
- }
- func (p *SamplingManagerClient) SetLastResponseMeta_(meta thrift.ResponseMeta) {
- p.meta = meta
- }
- // Parameters:
- // - ServiceName
- func (p *SamplingManagerClient) GetSamplingStrategy(ctx context.Context, serviceName string) (_r *SamplingStrategyResponse, _err error) {
- var _args2 SamplingManagerGetSamplingStrategyArgs
- _args2.ServiceName = serviceName
- var _result4 SamplingManagerGetSamplingStrategyResult
- var _meta3 thrift.ResponseMeta
- _meta3, _err = p.Client_().Call(ctx, "getSamplingStrategy", &_args2, &_result4)
- p.SetLastResponseMeta_(_meta3)
- if _err != nil {
- return
- }
- return _result4.GetSuccess(), nil
- }
- type SamplingManagerProcessor struct {
- processorMap map[string]thrift.TProcessorFunction
- handler SamplingManager
- }
- func (p *SamplingManagerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
- p.processorMap[key] = processor
- }
- func (p *SamplingManagerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
- processor, ok = p.processorMap[key]
- return processor, ok
- }
- func (p *SamplingManagerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
- return p.processorMap
- }
- func NewSamplingManagerProcessor(handler SamplingManager) *SamplingManagerProcessor {
- self5 := &SamplingManagerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}
- self5.processorMap["getSamplingStrategy"] = &samplingManagerProcessorGetSamplingStrategy{handler:handler}
- return self5
- }
- func (p *SamplingManagerProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
- name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)
- if err2 != nil { return false, thrift.WrapTException(err2) }
- if processor, ok := p.GetProcessorFunction(name); ok {
- return processor.Process(ctx, seqId, iprot, oprot)
- }
- iprot.Skip(ctx, thrift.STRUCT)
- iprot.ReadMessageEnd(ctx)
- x6 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name)
- oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)
- x6.Write(ctx, oprot)
- oprot.WriteMessageEnd(ctx)
- oprot.Flush(ctx)
- return false, x6
- }
- type samplingManagerProcessorGetSamplingStrategy struct {
- handler SamplingManager
- }
- func (p *samplingManagerProcessorGetSamplingStrategy) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
- args := SamplingManagerGetSamplingStrategyArgs{}
- var err2 error
- if err2 = args.Read(ctx, iprot); err2 != nil {
- iprot.ReadMessageEnd(ctx)
- x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error())
- oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.EXCEPTION, seqId)
- x.Write(ctx, oprot)
- oprot.WriteMessageEnd(ctx)
- oprot.Flush(ctx)
- return false, thrift.WrapTException(err2)
- }
- iprot.ReadMessageEnd(ctx)
- tickerCancel := func() {}
- // Start a goroutine to do server side connectivity check.
- if thrift.ServerConnectivityCheckInterval > 0 {
- var cancel context.CancelFunc
- ctx, cancel = context.WithCancel(ctx)
- defer cancel()
- var tickerCtx context.Context
- tickerCtx, tickerCancel = context.WithCancel(context.Background())
- defer tickerCancel()
- go func(ctx context.Context, cancel context.CancelFunc) {
- ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)
- defer ticker.Stop()
- for {
- select {
- case <-ctx.Done():
- return
- case <-ticker.C:
- if !iprot.Transport().IsOpen() {
- cancel()
- return
- }
- }
- }
- }(tickerCtx, cancel)
- }
- result := SamplingManagerGetSamplingStrategyResult{}
- var retval *SamplingStrategyResponse
- if retval, err2 = p.handler.GetSamplingStrategy(ctx, args.ServiceName); err2 != nil {
- tickerCancel()
- if err2 == thrift.ErrAbandonRequest {
- return false, thrift.WrapTException(err2)
- }
- x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getSamplingStrategy: " + err2.Error())
- oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.EXCEPTION, seqId)
- x.Write(ctx, oprot)
- oprot.WriteMessageEnd(ctx)
- oprot.Flush(ctx)
- return true, thrift.WrapTException(err2)
- } else {
- result.Success = retval
- }
- tickerCancel()
- if err2 = oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.REPLY, seqId); err2 != nil {
- err = thrift.WrapTException(err2)
- }
- if err2 = result.Write(ctx, oprot); err == nil && err2 != nil {
- err = thrift.WrapTException(err2)
- }
- if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil {
- err = thrift.WrapTException(err2)
- }
- if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
- err = thrift.WrapTException(err2)
- }
- if err != nil {
- return
- }
- return true, err
- }
- // HELPER FUNCTIONS AND STRUCTURES
- // Attributes:
- // - ServiceName
- type SamplingManagerGetSamplingStrategyArgs struct {
- ServiceName string `thrift:"serviceName,1" db:"serviceName" json:"serviceName"`
- }
- func NewSamplingManagerGetSamplingStrategyArgs() *SamplingManagerGetSamplingStrategyArgs {
- return &SamplingManagerGetSamplingStrategyArgs{}
- }
- func (p *SamplingManagerGetSamplingStrategyArgs) GetServiceName() string {
- return p.ServiceName
- }
- func (p *SamplingManagerGetSamplingStrategyArgs) Read(ctx context.Context, iprot thrift.TProtocol) error {
- if _, err := iprot.ReadStructBegin(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
- }
- for {
- _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
- if err != nil {
- return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
- }
- if fieldTypeId == thrift.STOP { break; }
- switch fieldId {
- case 1:
- if fieldTypeId == thrift.STRING {
- if err := p.ReadField1(ctx, iprot); err != nil {
- return err
- }
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- default:
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- if err := iprot.ReadFieldEnd(ctx); err != nil {
- return err
- }
- }
- if err := iprot.ReadStructEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
- }
- return nil
- }
- func (p *SamplingManagerGetSamplingStrategyArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
- if v, err := iprot.ReadString(ctx); err != nil {
- return thrift.PrependError("error reading field 1: ", err)
- } else {
- p.ServiceName = v
- }
- return nil
- }
- func (p *SamplingManagerGetSamplingStrategyArgs) Write(ctx context.Context, oprot thrift.TProtocol) error {
- if err := oprot.WriteStructBegin(ctx, "getSamplingStrategy_args"); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
- if p != nil {
- if err := p.writeField1(ctx, oprot); err != nil { return err }
- }
- if err := oprot.WriteFieldStop(ctx); err != nil {
- return thrift.PrependError("write field stop error: ", err) }
- if err := oprot.WriteStructEnd(ctx); err != nil {
- return thrift.PrependError("write struct stop error: ", err) }
- return nil
- }
- func (p *SamplingManagerGetSamplingStrategyArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if err := oprot.WriteFieldBegin(ctx, "serviceName", thrift.STRING, 1); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:serviceName: ", p), err) }
- if err := oprot.WriteString(ctx, string(p.ServiceName)); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T.serviceName (1) field write error: ", p), err) }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 1:serviceName: ", p), err) }
- return err
- }
- func (p *SamplingManagerGetSamplingStrategyArgs) String() string {
- if p == nil {
- return "<nil>"
- }
- return fmt.Sprintf("SamplingManagerGetSamplingStrategyArgs(%+v)", *p)
- }
- // Attributes:
- // - Success
- type SamplingManagerGetSamplingStrategyResult struct {
- Success *SamplingStrategyResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
- }
- func NewSamplingManagerGetSamplingStrategyResult() *SamplingManagerGetSamplingStrategyResult {
- return &SamplingManagerGetSamplingStrategyResult{}
- }
- var SamplingManagerGetSamplingStrategyResult_Success_DEFAULT *SamplingStrategyResponse
- func (p *SamplingManagerGetSamplingStrategyResult) GetSuccess() *SamplingStrategyResponse {
- if !p.IsSetSuccess() {
- return SamplingManagerGetSamplingStrategyResult_Success_DEFAULT
- }
- return p.Success
- }
- func (p *SamplingManagerGetSamplingStrategyResult) IsSetSuccess() bool {
- return p.Success != nil
- }
- func (p *SamplingManagerGetSamplingStrategyResult) Read(ctx context.Context, iprot thrift.TProtocol) error {
- if _, err := iprot.ReadStructBegin(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
- }
- for {
- _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
- if err != nil {
- return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
- }
- if fieldTypeId == thrift.STOP { break; }
- switch fieldId {
- case 0:
- if fieldTypeId == thrift.STRUCT {
- if err := p.ReadField0(ctx, iprot); err != nil {
- return err
- }
- } else {
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- default:
- if err := iprot.Skip(ctx, fieldTypeId); err != nil {
- return err
- }
- }
- if err := iprot.ReadFieldEnd(ctx); err != nil {
- return err
- }
- }
- if err := iprot.ReadStructEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
- }
- return nil
- }
- func (p *SamplingManagerGetSamplingStrategyResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error {
- p.Success = &SamplingStrategyResponse{}
- if err := p.Success.Read(ctx, iprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
- }
- return nil
- }
- func (p *SamplingManagerGetSamplingStrategyResult) Write(ctx context.Context, oprot thrift.TProtocol) error {
- if err := oprot.WriteStructBegin(ctx, "getSamplingStrategy_result"); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
- if p != nil {
- if err := p.writeField0(ctx, oprot); err != nil { return err }
- }
- if err := oprot.WriteFieldStop(ctx); err != nil {
- return thrift.PrependError("write field stop error: ", err) }
- if err := oprot.WriteStructEnd(ctx); err != nil {
- return thrift.PrependError("write struct stop error: ", err) }
- return nil
- }
- func (p *SamplingManagerGetSamplingStrategyResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) {
- if p.IsSetSuccess() {
- if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
- if err := p.Success.Write(ctx, oprot); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
- }
- if err := oprot.WriteFieldEnd(ctx); err != nil {
- return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
- }
- return err
- }
- func (p *SamplingManagerGetSamplingStrategyResult) String() string {
- if p == nil {
- return "<nil>"
- }
- return fmt.Sprintf("SamplingManagerGetSamplingStrategyResult(%+v)", *p)
- }
|