blob: 3bffa5b8eea977cef812c4331885d9ec330ad99a [file] [log] [blame]
// 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)
}