sampling.go 48 KB

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