1// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. 2 3package zipkincore 4 5import ( 6 "bytes" 7 "context" 8 "database/sql/driver" 9 "errors" 10 "fmt" 11 "go.opentelemetry.io/otel/exporters/trace/jaeger/internal/third_party/thrift/lib/go/thrift" 12 "time" 13) 14 15// (needed to ensure safety because of naive import list construction.) 16var _ = thrift.ZERO 17var _ = fmt.Printf 18var _ = context.Background 19var _ = time.Now 20var _ = bytes.Equal 21 22type AnnotationType int64 23 24const ( 25 AnnotationType_BOOL AnnotationType = 0 26 AnnotationType_BYTES AnnotationType = 1 27 AnnotationType_I16 AnnotationType = 2 28 AnnotationType_I32 AnnotationType = 3 29 AnnotationType_I64 AnnotationType = 4 30 AnnotationType_DOUBLE AnnotationType = 5 31 AnnotationType_STRING AnnotationType = 6 32) 33 34func (p AnnotationType) String() string { 35 switch p { 36 case AnnotationType_BOOL: 37 return "BOOL" 38 case AnnotationType_BYTES: 39 return "BYTES" 40 case AnnotationType_I16: 41 return "I16" 42 case AnnotationType_I32: 43 return "I32" 44 case AnnotationType_I64: 45 return "I64" 46 case AnnotationType_DOUBLE: 47 return "DOUBLE" 48 case AnnotationType_STRING: 49 return "STRING" 50 } 51 return "<UNSET>" 52} 53 54func AnnotationTypeFromString(s string) (AnnotationType, error) { 55 switch s { 56 case "BOOL": 57 return AnnotationType_BOOL, nil 58 case "BYTES": 59 return AnnotationType_BYTES, nil 60 case "I16": 61 return AnnotationType_I16, nil 62 case "I32": 63 return AnnotationType_I32, nil 64 case "I64": 65 return AnnotationType_I64, nil 66 case "DOUBLE": 67 return AnnotationType_DOUBLE, nil 68 case "STRING": 69 return AnnotationType_STRING, nil 70 } 71 return AnnotationType(0), fmt.Errorf("not a valid AnnotationType string") 72} 73 74func AnnotationTypePtr(v AnnotationType) *AnnotationType { return &v } 75 76func (p AnnotationType) MarshalText() ([]byte, error) { 77 return []byte(p.String()), nil 78} 79 80func (p *AnnotationType) UnmarshalText(text []byte) error { 81 q, err := AnnotationTypeFromString(string(text)) 82 if err != nil { 83 return err 84 } 85 *p = q 86 return nil 87} 88 89func (p *AnnotationType) Scan(value interface{}) error { 90 v, ok := value.(int64) 91 if !ok { 92 return errors.New("Scan value is not int64") 93 } 94 *p = AnnotationType(v) 95 return nil 96} 97 98func (p *AnnotationType) Value() (driver.Value, error) { 99 if p == nil { 100 return nil, nil 101 } 102 return int64(*p), nil 103} 104 105// Indicates the network context of a service recording an annotation with two 106// exceptions. 107// 108// When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR, 109// the endpoint indicates the source or destination of an RPC. This exception 110// allows zipkin to display network context of uninstrumented services, or 111// clients such as web browsers. 112// 113// Attributes: 114// - Ipv4: IPv4 host address packed into 4 bytes. 115// 116// Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 117// - Port: IPv4 port 118// 119// Note: this is to be treated as an unsigned integer, so watch for negatives. 120// 121// Conventionally, when the port isn't known, port = 0. 122// - ServiceName: Service name in lowercase, such as "memcache" or "zipkin-web" 123// 124// Conventionally, when the service name isn't known, service_name = "unknown". 125// - Ipv6: IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes() 126type Endpoint struct { 127 Ipv4 int32 `thrift:"ipv4,1" db:"ipv4" json:"ipv4"` 128 Port int16 `thrift:"port,2" db:"port" json:"port"` 129 ServiceName string `thrift:"service_name,3" db:"service_name" json:"service_name"` 130 Ipv6 []byte `thrift:"ipv6,4" db:"ipv6" json:"ipv6,omitempty"` 131} 132 133func NewEndpoint() *Endpoint { 134 return &Endpoint{} 135} 136 137func (p *Endpoint) GetIpv4() int32 { 138 return p.Ipv4 139} 140 141func (p *Endpoint) GetPort() int16 { 142 return p.Port 143} 144 145func (p *Endpoint) GetServiceName() string { 146 return p.ServiceName 147} 148 149var Endpoint_Ipv6_DEFAULT []byte 150 151func (p *Endpoint) GetIpv6() []byte { 152 return p.Ipv6 153} 154func (p *Endpoint) IsSetIpv6() bool { 155 return p.Ipv6 != nil 156} 157 158func (p *Endpoint) Read(ctx context.Context, iprot thrift.TProtocol) error { 159 if _, err := iprot.ReadStructBegin(ctx); err != nil { 160 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 161 } 162 163 for { 164 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) 165 if err != nil { 166 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 167 } 168 if fieldTypeId == thrift.STOP { 169 break 170 } 171 switch fieldId { 172 case 1: 173 if fieldTypeId == thrift.I32 { 174 if err := p.ReadField1(ctx, iprot); err != nil { 175 return err 176 } 177 } else { 178 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 179 return err 180 } 181 } 182 case 2: 183 if fieldTypeId == thrift.I16 { 184 if err := p.ReadField2(ctx, iprot); err != nil { 185 return err 186 } 187 } else { 188 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 189 return err 190 } 191 } 192 case 3: 193 if fieldTypeId == thrift.STRING { 194 if err := p.ReadField3(ctx, iprot); err != nil { 195 return err 196 } 197 } else { 198 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 199 return err 200 } 201 } 202 case 4: 203 if fieldTypeId == thrift.STRING { 204 if err := p.ReadField4(ctx, iprot); err != nil { 205 return err 206 } 207 } else { 208 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 209 return err 210 } 211 } 212 default: 213 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 214 return err 215 } 216 } 217 if err := iprot.ReadFieldEnd(ctx); err != nil { 218 return err 219 } 220 } 221 if err := iprot.ReadStructEnd(ctx); err != nil { 222 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 223 } 224 return nil 225} 226 227func (p *Endpoint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { 228 if v, err := iprot.ReadI32(ctx); err != nil { 229 return thrift.PrependError("error reading field 1: ", err) 230 } else { 231 p.Ipv4 = v 232 } 233 return nil 234} 235 236func (p *Endpoint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { 237 if v, err := iprot.ReadI16(ctx); err != nil { 238 return thrift.PrependError("error reading field 2: ", err) 239 } else { 240 p.Port = v 241 } 242 return nil 243} 244 245func (p *Endpoint) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { 246 if v, err := iprot.ReadString(ctx); err != nil { 247 return thrift.PrependError("error reading field 3: ", err) 248 } else { 249 p.ServiceName = v 250 } 251 return nil 252} 253 254func (p *Endpoint) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { 255 if v, err := iprot.ReadBinary(ctx); err != nil { 256 return thrift.PrependError("error reading field 4: ", err) 257 } else { 258 p.Ipv6 = v 259 } 260 return nil 261} 262 263func (p *Endpoint) Write(ctx context.Context, oprot thrift.TProtocol) error { 264 if err := oprot.WriteStructBegin(ctx, "Endpoint"); err != nil { 265 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 266 } 267 if p != nil { 268 if err := p.writeField1(ctx, oprot); err != nil { 269 return err 270 } 271 if err := p.writeField2(ctx, oprot); err != nil { 272 return err 273 } 274 if err := p.writeField3(ctx, oprot); err != nil { 275 return err 276 } 277 if err := p.writeField4(ctx, oprot); err != nil { 278 return err 279 } 280 } 281 if err := oprot.WriteFieldStop(ctx); err != nil { 282 return thrift.PrependError("write field stop error: ", err) 283 } 284 if err := oprot.WriteStructEnd(ctx); err != nil { 285 return thrift.PrependError("write struct stop error: ", err) 286 } 287 return nil 288} 289 290func (p *Endpoint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { 291 if err := oprot.WriteFieldBegin(ctx, "ipv4", thrift.I32, 1); err != nil { 292 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ipv4: ", p), err) 293 } 294 if err := oprot.WriteI32(ctx, int32(p.Ipv4)); err != nil { 295 return thrift.PrependError(fmt.Sprintf("%T.ipv4 (1) field write error: ", p), err) 296 } 297 if err := oprot.WriteFieldEnd(ctx); err != nil { 298 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ipv4: ", p), err) 299 } 300 return err 301} 302 303func (p *Endpoint) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { 304 if err := oprot.WriteFieldBegin(ctx, "port", thrift.I16, 2); err != nil { 305 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:port: ", p), err) 306 } 307 if err := oprot.WriteI16(ctx, int16(p.Port)); err != nil { 308 return thrift.PrependError(fmt.Sprintf("%T.port (2) field write error: ", p), err) 309 } 310 if err := oprot.WriteFieldEnd(ctx); err != nil { 311 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:port: ", p), err) 312 } 313 return err 314} 315 316func (p *Endpoint) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { 317 if err := oprot.WriteFieldBegin(ctx, "service_name", thrift.STRING, 3); err != nil { 318 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:service_name: ", p), err) 319 } 320 if err := oprot.WriteString(ctx, string(p.ServiceName)); err != nil { 321 return thrift.PrependError(fmt.Sprintf("%T.service_name (3) field write error: ", p), err) 322 } 323 if err := oprot.WriteFieldEnd(ctx); err != nil { 324 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:service_name: ", p), err) 325 } 326 return err 327} 328 329func (p *Endpoint) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { 330 if p.IsSetIpv6() { 331 if err := oprot.WriteFieldBegin(ctx, "ipv6", thrift.STRING, 4); err != nil { 332 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:ipv6: ", p), err) 333 } 334 if err := oprot.WriteBinary(ctx, p.Ipv6); err != nil { 335 return thrift.PrependError(fmt.Sprintf("%T.ipv6 (4) field write error: ", p), err) 336 } 337 if err := oprot.WriteFieldEnd(ctx); err != nil { 338 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:ipv6: ", p), err) 339 } 340 } 341 return err 342} 343 344func (p *Endpoint) Equals(other *Endpoint) bool { 345 if p == other { 346 return true 347 } else if p == nil || other == nil { 348 return false 349 } 350 if p.Ipv4 != other.Ipv4 { 351 return false 352 } 353 if p.Port != other.Port { 354 return false 355 } 356 if p.ServiceName != other.ServiceName { 357 return false 358 } 359 if bytes.Compare(p.Ipv6, other.Ipv6) != 0 { 360 return false 361 } 362 return true 363} 364 365func (p *Endpoint) String() string { 366 if p == nil { 367 return "<nil>" 368 } 369 return fmt.Sprintf("Endpoint(%+v)", *p) 370} 371 372// An annotation is similar to a log statement. It includes a host field which 373// allows these events to be attributed properly, and also aggregatable. 374// 375// Attributes: 376// - Timestamp: Microseconds from epoch. 377// 378// This value should use the most precise value possible. For example, 379// gettimeofday or syncing nanoTime against a tick of currentTimeMillis. 380// - Value 381// - Host: Always the host that recorded the event. By specifying the host you allow 382// rollup of all events (such as client requests to a service) by IP address. 383type Annotation struct { 384 Timestamp int64 `thrift:"timestamp,1" db:"timestamp" json:"timestamp"` 385 Value string `thrift:"value,2" db:"value" json:"value"` 386 Host *Endpoint `thrift:"host,3" db:"host" json:"host,omitempty"` 387} 388 389func NewAnnotation() *Annotation { 390 return &Annotation{} 391} 392 393func (p *Annotation) GetTimestamp() int64 { 394 return p.Timestamp 395} 396 397func (p *Annotation) GetValue() string { 398 return p.Value 399} 400 401var Annotation_Host_DEFAULT *Endpoint 402 403func (p *Annotation) GetHost() *Endpoint { 404 if !p.IsSetHost() { 405 return Annotation_Host_DEFAULT 406 } 407 return p.Host 408} 409func (p *Annotation) IsSetHost() bool { 410 return p.Host != nil 411} 412 413func (p *Annotation) Read(ctx context.Context, iprot thrift.TProtocol) error { 414 if _, err := iprot.ReadStructBegin(ctx); err != nil { 415 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 416 } 417 418 for { 419 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) 420 if err != nil { 421 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 422 } 423 if fieldTypeId == thrift.STOP { 424 break 425 } 426 switch fieldId { 427 case 1: 428 if fieldTypeId == thrift.I64 { 429 if err := p.ReadField1(ctx, iprot); err != nil { 430 return err 431 } 432 } else { 433 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 434 return err 435 } 436 } 437 case 2: 438 if fieldTypeId == thrift.STRING { 439 if err := p.ReadField2(ctx, iprot); err != nil { 440 return err 441 } 442 } else { 443 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 444 return err 445 } 446 } 447 case 3: 448 if fieldTypeId == thrift.STRUCT { 449 if err := p.ReadField3(ctx, iprot); err != nil { 450 return err 451 } 452 } else { 453 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 454 return err 455 } 456 } 457 default: 458 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 459 return err 460 } 461 } 462 if err := iprot.ReadFieldEnd(ctx); err != nil { 463 return err 464 } 465 } 466 if err := iprot.ReadStructEnd(ctx); err != nil { 467 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 468 } 469 return nil 470} 471 472func (p *Annotation) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { 473 if v, err := iprot.ReadI64(ctx); err != nil { 474 return thrift.PrependError("error reading field 1: ", err) 475 } else { 476 p.Timestamp = v 477 } 478 return nil 479} 480 481func (p *Annotation) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { 482 if v, err := iprot.ReadString(ctx); err != nil { 483 return thrift.PrependError("error reading field 2: ", err) 484 } else { 485 p.Value = v 486 } 487 return nil 488} 489 490func (p *Annotation) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { 491 p.Host = &Endpoint{} 492 if err := p.Host.Read(ctx, iprot); err != nil { 493 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Host), err) 494 } 495 return nil 496} 497 498func (p *Annotation) Write(ctx context.Context, oprot thrift.TProtocol) error { 499 if err := oprot.WriteStructBegin(ctx, "Annotation"); err != nil { 500 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 501 } 502 if p != nil { 503 if err := p.writeField1(ctx, oprot); err != nil { 504 return err 505 } 506 if err := p.writeField2(ctx, oprot); err != nil { 507 return err 508 } 509 if err := p.writeField3(ctx, oprot); err != nil { 510 return err 511 } 512 } 513 if err := oprot.WriteFieldStop(ctx); err != nil { 514 return thrift.PrependError("write field stop error: ", err) 515 } 516 if err := oprot.WriteStructEnd(ctx); err != nil { 517 return thrift.PrependError("write struct stop error: ", err) 518 } 519 return nil 520} 521 522func (p *Annotation) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { 523 if err := oprot.WriteFieldBegin(ctx, "timestamp", thrift.I64, 1); err != nil { 524 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:timestamp: ", p), err) 525 } 526 if err := oprot.WriteI64(ctx, int64(p.Timestamp)); err != nil { 527 return thrift.PrependError(fmt.Sprintf("%T.timestamp (1) field write error: ", p), err) 528 } 529 if err := oprot.WriteFieldEnd(ctx); err != nil { 530 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:timestamp: ", p), err) 531 } 532 return err 533} 534 535func (p *Annotation) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { 536 if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 2); err != nil { 537 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) 538 } 539 if err := oprot.WriteString(ctx, string(p.Value)); err != nil { 540 return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) 541 } 542 if err := oprot.WriteFieldEnd(ctx); err != nil { 543 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) 544 } 545 return err 546} 547 548func (p *Annotation) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { 549 if p.IsSetHost() { 550 if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRUCT, 3); err != nil { 551 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:host: ", p), err) 552 } 553 if err := p.Host.Write(ctx, oprot); err != nil { 554 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Host), err) 555 } 556 if err := oprot.WriteFieldEnd(ctx); err != nil { 557 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:host: ", p), err) 558 } 559 } 560 return err 561} 562 563func (p *Annotation) Equals(other *Annotation) bool { 564 if p == other { 565 return true 566 } else if p == nil || other == nil { 567 return false 568 } 569 if p.Timestamp != other.Timestamp { 570 return false 571 } 572 if p.Value != other.Value { 573 return false 574 } 575 if !p.Host.Equals(other.Host) { 576 return false 577 } 578 return true 579} 580 581func (p *Annotation) String() string { 582 if p == nil { 583 return "<nil>" 584 } 585 return fmt.Sprintf("Annotation(%+v)", *p) 586} 587 588// Binary annotations are tags applied to a Span to give it context. For 589// example, a binary annotation of "http.uri" could the path to a resource in a 590// RPC call. 591// 592// Binary annotations of type STRING are always queryable, though more a 593// historical implementation detail than a structural concern. 594// 595// Binary annotations can repeat, and vary on the host. Similar to Annotation, 596// the host indicates who logged the event. This allows you to tell the 597// difference between the client and server side of the same key. For example, 598// the key "http.uri" might be different on the client and server side due to 599// rewriting, like "/api/v1/myresource" vs "/myresource. Via the host field, 600// you can see the different points of view, which often help in debugging. 601// 602// Attributes: 603// - Key 604// - Value 605// - AnnotationType 606// - Host: The host that recorded tag, which allows you to differentiate between 607// multiple tags with the same key. There are two exceptions to this. 608// 609// When the key is CLIENT_ADDR or SERVER_ADDR, host indicates the source or 610// destination of an RPC. This exception allows zipkin to display network 611// context of uninstrumented services, or clients such as web browsers. 612type BinaryAnnotation struct { 613 Key string `thrift:"key,1" db:"key" json:"key"` 614 Value []byte `thrift:"value,2" db:"value" json:"value"` 615 AnnotationType AnnotationType `thrift:"annotation_type,3" db:"annotation_type" json:"annotation_type"` 616 Host *Endpoint `thrift:"host,4" db:"host" json:"host,omitempty"` 617} 618 619func NewBinaryAnnotation() *BinaryAnnotation { 620 return &BinaryAnnotation{} 621} 622 623func (p *BinaryAnnotation) GetKey() string { 624 return p.Key 625} 626 627func (p *BinaryAnnotation) GetValue() []byte { 628 return p.Value 629} 630 631func (p *BinaryAnnotation) GetAnnotationType() AnnotationType { 632 return p.AnnotationType 633} 634 635var BinaryAnnotation_Host_DEFAULT *Endpoint 636 637func (p *BinaryAnnotation) GetHost() *Endpoint { 638 if !p.IsSetHost() { 639 return BinaryAnnotation_Host_DEFAULT 640 } 641 return p.Host 642} 643func (p *BinaryAnnotation) IsSetHost() bool { 644 return p.Host != nil 645} 646 647func (p *BinaryAnnotation) Read(ctx context.Context, iprot thrift.TProtocol) error { 648 if _, err := iprot.ReadStructBegin(ctx); err != nil { 649 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 650 } 651 652 for { 653 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) 654 if err != nil { 655 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 656 } 657 if fieldTypeId == thrift.STOP { 658 break 659 } 660 switch fieldId { 661 case 1: 662 if fieldTypeId == thrift.STRING { 663 if err := p.ReadField1(ctx, iprot); err != nil { 664 return err 665 } 666 } else { 667 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 668 return err 669 } 670 } 671 case 2: 672 if fieldTypeId == thrift.STRING { 673 if err := p.ReadField2(ctx, iprot); err != nil { 674 return err 675 } 676 } else { 677 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 678 return err 679 } 680 } 681 case 3: 682 if fieldTypeId == thrift.I32 { 683 if err := p.ReadField3(ctx, iprot); err != nil { 684 return err 685 } 686 } else { 687 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 688 return err 689 } 690 } 691 case 4: 692 if fieldTypeId == thrift.STRUCT { 693 if err := p.ReadField4(ctx, iprot); err != nil { 694 return err 695 } 696 } else { 697 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 698 return err 699 } 700 } 701 default: 702 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 703 return err 704 } 705 } 706 if err := iprot.ReadFieldEnd(ctx); err != nil { 707 return err 708 } 709 } 710 if err := iprot.ReadStructEnd(ctx); err != nil { 711 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 712 } 713 return nil 714} 715 716func (p *BinaryAnnotation) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { 717 if v, err := iprot.ReadString(ctx); err != nil { 718 return thrift.PrependError("error reading field 1: ", err) 719 } else { 720 p.Key = v 721 } 722 return nil 723} 724 725func (p *BinaryAnnotation) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { 726 if v, err := iprot.ReadBinary(ctx); err != nil { 727 return thrift.PrependError("error reading field 2: ", err) 728 } else { 729 p.Value = v 730 } 731 return nil 732} 733 734func (p *BinaryAnnotation) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { 735 if v, err := iprot.ReadI32(ctx); err != nil { 736 return thrift.PrependError("error reading field 3: ", err) 737 } else { 738 temp := AnnotationType(v) 739 p.AnnotationType = temp 740 } 741 return nil 742} 743 744func (p *BinaryAnnotation) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { 745 p.Host = &Endpoint{} 746 if err := p.Host.Read(ctx, iprot); err != nil { 747 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Host), err) 748 } 749 return nil 750} 751 752func (p *BinaryAnnotation) Write(ctx context.Context, oprot thrift.TProtocol) error { 753 if err := oprot.WriteStructBegin(ctx, "BinaryAnnotation"); err != nil { 754 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 755 } 756 if p != nil { 757 if err := p.writeField1(ctx, oprot); err != nil { 758 return err 759 } 760 if err := p.writeField2(ctx, oprot); err != nil { 761 return err 762 } 763 if err := p.writeField3(ctx, oprot); err != nil { 764 return err 765 } 766 if err := p.writeField4(ctx, oprot); err != nil { 767 return err 768 } 769 } 770 if err := oprot.WriteFieldStop(ctx); err != nil { 771 return thrift.PrependError("write field stop error: ", err) 772 } 773 if err := oprot.WriteStructEnd(ctx); err != nil { 774 return thrift.PrependError("write struct stop error: ", err) 775 } 776 return nil 777} 778 779func (p *BinaryAnnotation) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { 780 if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRING, 1); err != nil { 781 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) 782 } 783 if err := oprot.WriteString(ctx, string(p.Key)); err != nil { 784 return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) 785 } 786 if err := oprot.WriteFieldEnd(ctx); err != nil { 787 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) 788 } 789 return err 790} 791 792func (p *BinaryAnnotation) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { 793 if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 2); err != nil { 794 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) 795 } 796 if err := oprot.WriteBinary(ctx, p.Value); err != nil { 797 return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) 798 } 799 if err := oprot.WriteFieldEnd(ctx); err != nil { 800 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) 801 } 802 return err 803} 804 805func (p *BinaryAnnotation) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { 806 if err := oprot.WriteFieldBegin(ctx, "annotation_type", thrift.I32, 3); err != nil { 807 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:annotation_type: ", p), err) 808 } 809 if err := oprot.WriteI32(ctx, int32(p.AnnotationType)); err != nil { 810 return thrift.PrependError(fmt.Sprintf("%T.annotation_type (3) field write error: ", p), err) 811 } 812 if err := oprot.WriteFieldEnd(ctx); err != nil { 813 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:annotation_type: ", p), err) 814 } 815 return err 816} 817 818func (p *BinaryAnnotation) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { 819 if p.IsSetHost() { 820 if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRUCT, 4); err != nil { 821 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:host: ", p), err) 822 } 823 if err := p.Host.Write(ctx, oprot); err != nil { 824 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Host), err) 825 } 826 if err := oprot.WriteFieldEnd(ctx); err != nil { 827 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:host: ", p), err) 828 } 829 } 830 return err 831} 832 833func (p *BinaryAnnotation) Equals(other *BinaryAnnotation) bool { 834 if p == other { 835 return true 836 } else if p == nil || other == nil { 837 return false 838 } 839 if p.Key != other.Key { 840 return false 841 } 842 if bytes.Compare(p.Value, other.Value) != 0 { 843 return false 844 } 845 if p.AnnotationType != other.AnnotationType { 846 return false 847 } 848 if !p.Host.Equals(other.Host) { 849 return false 850 } 851 return true 852} 853 854func (p *BinaryAnnotation) String() string { 855 if p == nil { 856 return "<nil>" 857 } 858 return fmt.Sprintf("BinaryAnnotation(%+v)", *p) 859} 860 861// A trace is a series of spans (often RPC calls) which form a latency tree. 862// 863// The root span is where trace_id = id and parent_id = Nil. The root span is 864// usually the longest interval in the trace, starting with a SERVER_RECV 865// annotation and ending with a SERVER_SEND. 866// 867// Attributes: 868// - TraceID 869// - Name: Span name in lowercase, rpc method for example 870// 871// Conventionally, when the span name isn't known, name = "unknown". 872// - ID 873// - ParentID 874// - Annotations 875// - BinaryAnnotations 876// - Debug 877// - Timestamp: Microseconds from epoch of the creation of this span. 878// 879// This value should be set directly by instrumentation, using the most 880// precise value possible. For example, gettimeofday or syncing nanoTime 881// against a tick of currentTimeMillis. 882// 883// For compatibility with instrumentation that precede this field, collectors 884// or span stores can derive this via Annotation.timestamp. 885// For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp. 886// 887// This field is optional for compatibility with old data: first-party span 888// stores are expected to support this at time of introduction. 889// - Duration: Measurement of duration in microseconds, used to support queries. 890// 891// This value should be set directly, where possible. Doing so encourages 892// precise measurement decoupled from problems of clocks, such as skew or NTP 893// updates causing time to move backwards. 894// 895// For compatibility with instrumentation that precede this field, collectors 896// or span stores can derive this by subtracting Annotation.timestamp. 897// For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp. 898// 899// If this field is persisted as unset, zipkin will continue to work, except 900// duration query support will be implementation-specific. Similarly, setting 901// this field non-atomically is implementation-specific. 902// 903// This field is i64 vs i32 to support spans longer than 35 minutes. 904// - TraceIDHigh: Optional unique 8-byte additional identifier for a trace. If non zero, this 905// means the trace uses 128 bit traceIds instead of 64 bit. 906type Span struct { 907 TraceID int64 `thrift:"trace_id,1" db:"trace_id" json:"trace_id"` 908 // unused field # 2 909 Name string `thrift:"name,3" db:"name" json:"name"` 910 ID int64 `thrift:"id,4" db:"id" json:"id"` 911 ParentID *int64 `thrift:"parent_id,5" db:"parent_id" json:"parent_id,omitempty"` 912 Annotations []*Annotation `thrift:"annotations,6" db:"annotations" json:"annotations"` 913 // unused field # 7 914 BinaryAnnotations []*BinaryAnnotation `thrift:"binary_annotations,8" db:"binary_annotations" json:"binary_annotations"` 915 Debug bool `thrift:"debug,9" db:"debug" json:"debug"` 916 Timestamp *int64 `thrift:"timestamp,10" db:"timestamp" json:"timestamp,omitempty"` 917 Duration *int64 `thrift:"duration,11" db:"duration" json:"duration,omitempty"` 918 TraceIDHigh *int64 `thrift:"trace_id_high,12" db:"trace_id_high" json:"trace_id_high,omitempty"` 919} 920 921func NewSpan() *Span { 922 return &Span{} 923} 924 925func (p *Span) GetTraceID() int64 { 926 return p.TraceID 927} 928 929func (p *Span) GetName() string { 930 return p.Name 931} 932 933func (p *Span) GetID() int64 { 934 return p.ID 935} 936 937var Span_ParentID_DEFAULT int64 938 939func (p *Span) GetParentID() int64 { 940 if !p.IsSetParentID() { 941 return Span_ParentID_DEFAULT 942 } 943 return *p.ParentID 944} 945 946func (p *Span) GetAnnotations() []*Annotation { 947 return p.Annotations 948} 949 950func (p *Span) GetBinaryAnnotations() []*BinaryAnnotation { 951 return p.BinaryAnnotations 952} 953 954var Span_Debug_DEFAULT bool = false 955 956func (p *Span) GetDebug() bool { 957 return p.Debug 958} 959 960var Span_Timestamp_DEFAULT int64 961 962func (p *Span) GetTimestamp() int64 { 963 if !p.IsSetTimestamp() { 964 return Span_Timestamp_DEFAULT 965 } 966 return *p.Timestamp 967} 968 969var Span_Duration_DEFAULT int64 970 971func (p *Span) GetDuration() int64 { 972 if !p.IsSetDuration() { 973 return Span_Duration_DEFAULT 974 } 975 return *p.Duration 976} 977 978var Span_TraceIDHigh_DEFAULT int64 979 980func (p *Span) GetTraceIDHigh() int64 { 981 if !p.IsSetTraceIDHigh() { 982 return Span_TraceIDHigh_DEFAULT 983 } 984 return *p.TraceIDHigh 985} 986func (p *Span) IsSetParentID() bool { 987 return p.ParentID != nil 988} 989 990func (p *Span) IsSetDebug() bool { 991 return p.Debug != Span_Debug_DEFAULT 992} 993 994func (p *Span) IsSetTimestamp() bool { 995 return p.Timestamp != nil 996} 997 998func (p *Span) IsSetDuration() bool { 999 return p.Duration != nil 1000} 1001 1002func (p *Span) IsSetTraceIDHigh() bool { 1003 return p.TraceIDHigh != nil 1004} 1005 1006func (p *Span) Read(ctx context.Context, iprot thrift.TProtocol) error { 1007 if _, err := iprot.ReadStructBegin(ctx); err != nil { 1008 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 1009 } 1010 1011 for { 1012 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) 1013 if err != nil { 1014 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 1015 } 1016 if fieldTypeId == thrift.STOP { 1017 break 1018 } 1019 switch fieldId { 1020 case 1: 1021 if fieldTypeId == thrift.I64 { 1022 if err := p.ReadField1(ctx, iprot); err != nil { 1023 return err 1024 } 1025 } else { 1026 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1027 return err 1028 } 1029 } 1030 case 3: 1031 if fieldTypeId == thrift.STRING { 1032 if err := p.ReadField3(ctx, iprot); err != nil { 1033 return err 1034 } 1035 } else { 1036 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1037 return err 1038 } 1039 } 1040 case 4: 1041 if fieldTypeId == thrift.I64 { 1042 if err := p.ReadField4(ctx, iprot); err != nil { 1043 return err 1044 } 1045 } else { 1046 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1047 return err 1048 } 1049 } 1050 case 5: 1051 if fieldTypeId == thrift.I64 { 1052 if err := p.ReadField5(ctx, iprot); err != nil { 1053 return err 1054 } 1055 } else { 1056 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1057 return err 1058 } 1059 } 1060 case 6: 1061 if fieldTypeId == thrift.LIST { 1062 if err := p.ReadField6(ctx, iprot); err != nil { 1063 return err 1064 } 1065 } else { 1066 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1067 return err 1068 } 1069 } 1070 case 8: 1071 if fieldTypeId == thrift.LIST { 1072 if err := p.ReadField8(ctx, iprot); err != nil { 1073 return err 1074 } 1075 } else { 1076 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1077 return err 1078 } 1079 } 1080 case 9: 1081 if fieldTypeId == thrift.BOOL { 1082 if err := p.ReadField9(ctx, iprot); err != nil { 1083 return err 1084 } 1085 } else { 1086 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1087 return err 1088 } 1089 } 1090 case 10: 1091 if fieldTypeId == thrift.I64 { 1092 if err := p.ReadField10(ctx, iprot); err != nil { 1093 return err 1094 } 1095 } else { 1096 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1097 return err 1098 } 1099 } 1100 case 11: 1101 if fieldTypeId == thrift.I64 { 1102 if err := p.ReadField11(ctx, iprot); err != nil { 1103 return err 1104 } 1105 } else { 1106 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1107 return err 1108 } 1109 } 1110 case 12: 1111 if fieldTypeId == thrift.I64 { 1112 if err := p.ReadField12(ctx, iprot); err != nil { 1113 return err 1114 } 1115 } else { 1116 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1117 return err 1118 } 1119 } 1120 default: 1121 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1122 return err 1123 } 1124 } 1125 if err := iprot.ReadFieldEnd(ctx); err != nil { 1126 return err 1127 } 1128 } 1129 if err := iprot.ReadStructEnd(ctx); err != nil { 1130 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1131 } 1132 return nil 1133} 1134 1135func (p *Span) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { 1136 if v, err := iprot.ReadI64(ctx); err != nil { 1137 return thrift.PrependError("error reading field 1: ", err) 1138 } else { 1139 p.TraceID = v 1140 } 1141 return nil 1142} 1143 1144func (p *Span) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { 1145 if v, err := iprot.ReadString(ctx); err != nil { 1146 return thrift.PrependError("error reading field 3: ", err) 1147 } else { 1148 p.Name = v 1149 } 1150 return nil 1151} 1152 1153func (p *Span) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { 1154 if v, err := iprot.ReadI64(ctx); err != nil { 1155 return thrift.PrependError("error reading field 4: ", err) 1156 } else { 1157 p.ID = v 1158 } 1159 return nil 1160} 1161 1162func (p *Span) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { 1163 if v, err := iprot.ReadI64(ctx); err != nil { 1164 return thrift.PrependError("error reading field 5: ", err) 1165 } else { 1166 p.ParentID = &v 1167 } 1168 return nil 1169} 1170 1171func (p *Span) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { 1172 _, size, err := iprot.ReadListBegin(ctx) 1173 if err != nil { 1174 return thrift.PrependError("error reading list begin: ", err) 1175 } 1176 tSlice := make([]*Annotation, 0, size) 1177 p.Annotations = tSlice 1178 for i := 0; i < size; i++ { 1179 _elem0 := &Annotation{} 1180 if err := _elem0.Read(ctx, iprot); err != nil { 1181 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem0), err) 1182 } 1183 p.Annotations = append(p.Annotations, _elem0) 1184 } 1185 if err := iprot.ReadListEnd(ctx); err != nil { 1186 return thrift.PrependError("error reading list end: ", err) 1187 } 1188 return nil 1189} 1190 1191func (p *Span) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { 1192 _, size, err := iprot.ReadListBegin(ctx) 1193 if err != nil { 1194 return thrift.PrependError("error reading list begin: ", err) 1195 } 1196 tSlice := make([]*BinaryAnnotation, 0, size) 1197 p.BinaryAnnotations = tSlice 1198 for i := 0; i < size; i++ { 1199 _elem1 := &BinaryAnnotation{} 1200 if err := _elem1.Read(ctx, iprot); err != nil { 1201 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem1), err) 1202 } 1203 p.BinaryAnnotations = append(p.BinaryAnnotations, _elem1) 1204 } 1205 if err := iprot.ReadListEnd(ctx); err != nil { 1206 return thrift.PrependError("error reading list end: ", err) 1207 } 1208 return nil 1209} 1210 1211func (p *Span) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { 1212 if v, err := iprot.ReadBool(ctx); err != nil { 1213 return thrift.PrependError("error reading field 9: ", err) 1214 } else { 1215 p.Debug = v 1216 } 1217 return nil 1218} 1219 1220func (p *Span) ReadField10(ctx context.Context, iprot thrift.TProtocol) error { 1221 if v, err := iprot.ReadI64(ctx); err != nil { 1222 return thrift.PrependError("error reading field 10: ", err) 1223 } else { 1224 p.Timestamp = &v 1225 } 1226 return nil 1227} 1228 1229func (p *Span) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { 1230 if v, err := iprot.ReadI64(ctx); err != nil { 1231 return thrift.PrependError("error reading field 11: ", err) 1232 } else { 1233 p.Duration = &v 1234 } 1235 return nil 1236} 1237 1238func (p *Span) ReadField12(ctx context.Context, iprot thrift.TProtocol) error { 1239 if v, err := iprot.ReadI64(ctx); err != nil { 1240 return thrift.PrependError("error reading field 12: ", err) 1241 } else { 1242 p.TraceIDHigh = &v 1243 } 1244 return nil 1245} 1246 1247func (p *Span) Write(ctx context.Context, oprot thrift.TProtocol) error { 1248 if err := oprot.WriteStructBegin(ctx, "Span"); err != nil { 1249 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 1250 } 1251 if p != nil { 1252 if err := p.writeField1(ctx, oprot); err != nil { 1253 return err 1254 } 1255 if err := p.writeField3(ctx, oprot); err != nil { 1256 return err 1257 } 1258 if err := p.writeField4(ctx, oprot); err != nil { 1259 return err 1260 } 1261 if err := p.writeField5(ctx, oprot); err != nil { 1262 return err 1263 } 1264 if err := p.writeField6(ctx, oprot); err != nil { 1265 return err 1266 } 1267 if err := p.writeField8(ctx, oprot); err != nil { 1268 return err 1269 } 1270 if err := p.writeField9(ctx, oprot); err != nil { 1271 return err 1272 } 1273 if err := p.writeField10(ctx, oprot); err != nil { 1274 return err 1275 } 1276 if err := p.writeField11(ctx, oprot); err != nil { 1277 return err 1278 } 1279 if err := p.writeField12(ctx, oprot); err != nil { 1280 return err 1281 } 1282 } 1283 if err := oprot.WriteFieldStop(ctx); err != nil { 1284 return thrift.PrependError("write field stop error: ", err) 1285 } 1286 if err := oprot.WriteStructEnd(ctx); err != nil { 1287 return thrift.PrependError("write struct stop error: ", err) 1288 } 1289 return nil 1290} 1291 1292func (p *Span) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { 1293 if err := oprot.WriteFieldBegin(ctx, "trace_id", thrift.I64, 1); err != nil { 1294 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:trace_id: ", p), err) 1295 } 1296 if err := oprot.WriteI64(ctx, int64(p.TraceID)); err != nil { 1297 return thrift.PrependError(fmt.Sprintf("%T.trace_id (1) field write error: ", p), err) 1298 } 1299 if err := oprot.WriteFieldEnd(ctx); err != nil { 1300 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:trace_id: ", p), err) 1301 } 1302 return err 1303} 1304 1305func (p *Span) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { 1306 if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 3); err != nil { 1307 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:name: ", p), err) 1308 } 1309 if err := oprot.WriteString(ctx, string(p.Name)); err != nil { 1310 return thrift.PrependError(fmt.Sprintf("%T.name (3) field write error: ", p), err) 1311 } 1312 if err := oprot.WriteFieldEnd(ctx); err != nil { 1313 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:name: ", p), err) 1314 } 1315 return err 1316} 1317 1318func (p *Span) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { 1319 if err := oprot.WriteFieldBegin(ctx, "id", thrift.I64, 4); err != nil { 1320 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:id: ", p), err) 1321 } 1322 if err := oprot.WriteI64(ctx, int64(p.ID)); err != nil { 1323 return thrift.PrependError(fmt.Sprintf("%T.id (4) field write error: ", p), err) 1324 } 1325 if err := oprot.WriteFieldEnd(ctx); err != nil { 1326 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:id: ", p), err) 1327 } 1328 return err 1329} 1330 1331func (p *Span) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { 1332 if p.IsSetParentID() { 1333 if err := oprot.WriteFieldBegin(ctx, "parent_id", thrift.I64, 5); err != nil { 1334 return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:parent_id: ", p), err) 1335 } 1336 if err := oprot.WriteI64(ctx, int64(*p.ParentID)); err != nil { 1337 return thrift.PrependError(fmt.Sprintf("%T.parent_id (5) field write error: ", p), err) 1338 } 1339 if err := oprot.WriteFieldEnd(ctx); err != nil { 1340 return thrift.PrependError(fmt.Sprintf("%T write field end error 5:parent_id: ", p), err) 1341 } 1342 } 1343 return err 1344} 1345 1346func (p *Span) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { 1347 if err := oprot.WriteFieldBegin(ctx, "annotations", thrift.LIST, 6); err != nil { 1348 return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:annotations: ", p), err) 1349 } 1350 if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Annotations)); err != nil { 1351 return thrift.PrependError("error writing list begin: ", err) 1352 } 1353 for _, v := range p.Annotations { 1354 if err := v.Write(ctx, oprot); err != nil { 1355 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1356 } 1357 } 1358 if err := oprot.WriteListEnd(ctx); err != nil { 1359 return thrift.PrependError("error writing list end: ", err) 1360 } 1361 if err := oprot.WriteFieldEnd(ctx); err != nil { 1362 return thrift.PrependError(fmt.Sprintf("%T write field end error 6:annotations: ", p), err) 1363 } 1364 return err 1365} 1366 1367func (p *Span) writeField8(ctx context.Context, oprot thrift.TProtocol) (err error) { 1368 if err := oprot.WriteFieldBegin(ctx, "binary_annotations", thrift.LIST, 8); err != nil { 1369 return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:binary_annotations: ", p), err) 1370 } 1371 if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.BinaryAnnotations)); err != nil { 1372 return thrift.PrependError("error writing list begin: ", err) 1373 } 1374 for _, v := range p.BinaryAnnotations { 1375 if err := v.Write(ctx, oprot); err != nil { 1376 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1377 } 1378 } 1379 if err := oprot.WriteListEnd(ctx); err != nil { 1380 return thrift.PrependError("error writing list end: ", err) 1381 } 1382 if err := oprot.WriteFieldEnd(ctx); err != nil { 1383 return thrift.PrependError(fmt.Sprintf("%T write field end error 8:binary_annotations: ", p), err) 1384 } 1385 return err 1386} 1387 1388func (p *Span) writeField9(ctx context.Context, oprot thrift.TProtocol) (err error) { 1389 if p.IsSetDebug() { 1390 if err := oprot.WriteFieldBegin(ctx, "debug", thrift.BOOL, 9); err != nil { 1391 return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:debug: ", p), err) 1392 } 1393 if err := oprot.WriteBool(ctx, bool(p.Debug)); err != nil { 1394 return thrift.PrependError(fmt.Sprintf("%T.debug (9) field write error: ", p), err) 1395 } 1396 if err := oprot.WriteFieldEnd(ctx); err != nil { 1397 return thrift.PrependError(fmt.Sprintf("%T write field end error 9:debug: ", p), err) 1398 } 1399 } 1400 return err 1401} 1402 1403func (p *Span) writeField10(ctx context.Context, oprot thrift.TProtocol) (err error) { 1404 if p.IsSetTimestamp() { 1405 if err := oprot.WriteFieldBegin(ctx, "timestamp", thrift.I64, 10); err != nil { 1406 return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:timestamp: ", p), err) 1407 } 1408 if err := oprot.WriteI64(ctx, int64(*p.Timestamp)); err != nil { 1409 return thrift.PrependError(fmt.Sprintf("%T.timestamp (10) field write error: ", p), err) 1410 } 1411 if err := oprot.WriteFieldEnd(ctx); err != nil { 1412 return thrift.PrependError(fmt.Sprintf("%T write field end error 10:timestamp: ", p), err) 1413 } 1414 } 1415 return err 1416} 1417 1418func (p *Span) writeField11(ctx context.Context, oprot thrift.TProtocol) (err error) { 1419 if p.IsSetDuration() { 1420 if err := oprot.WriteFieldBegin(ctx, "duration", thrift.I64, 11); err != nil { 1421 return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:duration: ", p), err) 1422 } 1423 if err := oprot.WriteI64(ctx, int64(*p.Duration)); err != nil { 1424 return thrift.PrependError(fmt.Sprintf("%T.duration (11) field write error: ", p), err) 1425 } 1426 if err := oprot.WriteFieldEnd(ctx); err != nil { 1427 return thrift.PrependError(fmt.Sprintf("%T write field end error 11:duration: ", p), err) 1428 } 1429 } 1430 return err 1431} 1432 1433func (p *Span) writeField12(ctx context.Context, oprot thrift.TProtocol) (err error) { 1434 if p.IsSetTraceIDHigh() { 1435 if err := oprot.WriteFieldBegin(ctx, "trace_id_high", thrift.I64, 12); err != nil { 1436 return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:trace_id_high: ", p), err) 1437 } 1438 if err := oprot.WriteI64(ctx, int64(*p.TraceIDHigh)); err != nil { 1439 return thrift.PrependError(fmt.Sprintf("%T.trace_id_high (12) field write error: ", p), err) 1440 } 1441 if err := oprot.WriteFieldEnd(ctx); err != nil { 1442 return thrift.PrependError(fmt.Sprintf("%T write field end error 12:trace_id_high: ", p), err) 1443 } 1444 } 1445 return err 1446} 1447 1448func (p *Span) Equals(other *Span) bool { 1449 if p == other { 1450 return true 1451 } else if p == nil || other == nil { 1452 return false 1453 } 1454 if p.TraceID != other.TraceID { 1455 return false 1456 } 1457 if p.Name != other.Name { 1458 return false 1459 } 1460 if p.ID != other.ID { 1461 return false 1462 } 1463 if p.ParentID != other.ParentID { 1464 if p.ParentID == nil || other.ParentID == nil { 1465 return false 1466 } 1467 if (*p.ParentID) != (*other.ParentID) { 1468 return false 1469 } 1470 } 1471 if len(p.Annotations) != len(other.Annotations) { 1472 return false 1473 } 1474 for i, _tgt := range p.Annotations { 1475 _src2 := other.Annotations[i] 1476 if !_tgt.Equals(_src2) { 1477 return false 1478 } 1479 } 1480 if len(p.BinaryAnnotations) != len(other.BinaryAnnotations) { 1481 return false 1482 } 1483 for i, _tgt := range p.BinaryAnnotations { 1484 _src3 := other.BinaryAnnotations[i] 1485 if !_tgt.Equals(_src3) { 1486 return false 1487 } 1488 } 1489 if p.Debug != other.Debug { 1490 return false 1491 } 1492 if p.Timestamp != other.Timestamp { 1493 if p.Timestamp == nil || other.Timestamp == nil { 1494 return false 1495 } 1496 if (*p.Timestamp) != (*other.Timestamp) { 1497 return false 1498 } 1499 } 1500 if p.Duration != other.Duration { 1501 if p.Duration == nil || other.Duration == nil { 1502 return false 1503 } 1504 if (*p.Duration) != (*other.Duration) { 1505 return false 1506 } 1507 } 1508 if p.TraceIDHigh != other.TraceIDHigh { 1509 if p.TraceIDHigh == nil || other.TraceIDHigh == nil { 1510 return false 1511 } 1512 if (*p.TraceIDHigh) != (*other.TraceIDHigh) { 1513 return false 1514 } 1515 } 1516 return true 1517} 1518 1519func (p *Span) String() string { 1520 if p == nil { 1521 return "<nil>" 1522 } 1523 return fmt.Sprintf("Span(%+v)", *p) 1524} 1525 1526// Attributes: 1527// - Ok 1528type Response struct { 1529 Ok bool `thrift:"ok,1,required" db:"ok" json:"ok"` 1530} 1531 1532func NewResponse() *Response { 1533 return &Response{} 1534} 1535 1536func (p *Response) GetOk() bool { 1537 return p.Ok 1538} 1539func (p *Response) Read(ctx context.Context, iprot thrift.TProtocol) error { 1540 if _, err := iprot.ReadStructBegin(ctx); err != nil { 1541 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 1542 } 1543 1544 var issetOk bool = false 1545 1546 for { 1547 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) 1548 if err != nil { 1549 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 1550 } 1551 if fieldTypeId == thrift.STOP { 1552 break 1553 } 1554 switch fieldId { 1555 case 1: 1556 if fieldTypeId == thrift.BOOL { 1557 if err := p.ReadField1(ctx, iprot); err != nil { 1558 return err 1559 } 1560 issetOk = true 1561 } else { 1562 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1563 return err 1564 } 1565 } 1566 default: 1567 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1568 return err 1569 } 1570 } 1571 if err := iprot.ReadFieldEnd(ctx); err != nil { 1572 return err 1573 } 1574 } 1575 if err := iprot.ReadStructEnd(ctx); err != nil { 1576 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1577 } 1578 if !issetOk { 1579 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Ok is not set")) 1580 } 1581 return nil 1582} 1583 1584func (p *Response) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { 1585 if v, err := iprot.ReadBool(ctx); err != nil { 1586 return thrift.PrependError("error reading field 1: ", err) 1587 } else { 1588 p.Ok = v 1589 } 1590 return nil 1591} 1592 1593func (p *Response) Write(ctx context.Context, oprot thrift.TProtocol) error { 1594 if err := oprot.WriteStructBegin(ctx, "Response"); err != nil { 1595 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 1596 } 1597 if p != nil { 1598 if err := p.writeField1(ctx, oprot); err != nil { 1599 return err 1600 } 1601 } 1602 if err := oprot.WriteFieldStop(ctx); err != nil { 1603 return thrift.PrependError("write field stop error: ", err) 1604 } 1605 if err := oprot.WriteStructEnd(ctx); err != nil { 1606 return thrift.PrependError("write struct stop error: ", err) 1607 } 1608 return nil 1609} 1610 1611func (p *Response) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { 1612 if err := oprot.WriteFieldBegin(ctx, "ok", thrift.BOOL, 1); err != nil { 1613 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ok: ", p), err) 1614 } 1615 if err := oprot.WriteBool(ctx, bool(p.Ok)); err != nil { 1616 return thrift.PrependError(fmt.Sprintf("%T.ok (1) field write error: ", p), err) 1617 } 1618 if err := oprot.WriteFieldEnd(ctx); err != nil { 1619 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ok: ", p), err) 1620 } 1621 return err 1622} 1623 1624func (p *Response) Equals(other *Response) bool { 1625 if p == other { 1626 return true 1627 } else if p == nil || other == nil { 1628 return false 1629 } 1630 if p.Ok != other.Ok { 1631 return false 1632 } 1633 return true 1634} 1635 1636func (p *Response) String() string { 1637 if p == nil { 1638 return "<nil>" 1639 } 1640 return fmt.Sprintf("Response(%+v)", *p) 1641} 1642 1643type ZipkinCollector interface { 1644 // Parameters: 1645 // - Spans 1646 SubmitZipkinBatch(ctx context.Context, spans []*Span) (_r []*Response, _err error) 1647} 1648 1649type ZipkinCollectorClient struct { 1650 c thrift.TClient 1651 meta thrift.ResponseMeta 1652} 1653 1654func NewZipkinCollectorClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ZipkinCollectorClient { 1655 return &ZipkinCollectorClient{ 1656 c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), 1657 } 1658} 1659 1660func NewZipkinCollectorClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ZipkinCollectorClient { 1661 return &ZipkinCollectorClient{ 1662 c: thrift.NewTStandardClient(iprot, oprot), 1663 } 1664} 1665 1666func NewZipkinCollectorClient(c thrift.TClient) *ZipkinCollectorClient { 1667 return &ZipkinCollectorClient{ 1668 c: c, 1669 } 1670} 1671 1672func (p *ZipkinCollectorClient) Client_() thrift.TClient { 1673 return p.c 1674} 1675 1676func (p *ZipkinCollectorClient) LastResponseMeta_() thrift.ResponseMeta { 1677 return p.meta 1678} 1679 1680func (p *ZipkinCollectorClient) SetLastResponseMeta_(meta thrift.ResponseMeta) { 1681 p.meta = meta 1682} 1683 1684// Parameters: 1685// - Spans 1686func (p *ZipkinCollectorClient) SubmitZipkinBatch(ctx context.Context, spans []*Span) (_r []*Response, _err error) { 1687 var _args4 ZipkinCollectorSubmitZipkinBatchArgs 1688 _args4.Spans = spans 1689 var _result6 ZipkinCollectorSubmitZipkinBatchResult 1690 var _meta5 thrift.ResponseMeta 1691 _meta5, _err = p.Client_().Call(ctx, "submitZipkinBatch", &_args4, &_result6) 1692 p.SetLastResponseMeta_(_meta5) 1693 if _err != nil { 1694 return 1695 } 1696 return _result6.GetSuccess(), nil 1697} 1698 1699type ZipkinCollectorProcessor struct { 1700 processorMap map[string]thrift.TProcessorFunction 1701 handler ZipkinCollector 1702} 1703 1704func (p *ZipkinCollectorProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { 1705 p.processorMap[key] = processor 1706} 1707 1708func (p *ZipkinCollectorProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { 1709 processor, ok = p.processorMap[key] 1710 return processor, ok 1711} 1712 1713func (p *ZipkinCollectorProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { 1714 return p.processorMap 1715} 1716 1717func NewZipkinCollectorProcessor(handler ZipkinCollector) *ZipkinCollectorProcessor { 1718 1719 self7 := &ZipkinCollectorProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} 1720 self7.processorMap["submitZipkinBatch"] = &zipkinCollectorProcessorSubmitZipkinBatch{handler: handler} 1721 return self7 1722} 1723 1724func (p *ZipkinCollectorProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { 1725 name, _, seqId, err2 := iprot.ReadMessageBegin(ctx) 1726 if err2 != nil { 1727 return false, thrift.WrapTException(err2) 1728 } 1729 if processor, ok := p.GetProcessorFunction(name); ok { 1730 return processor.Process(ctx, seqId, iprot, oprot) 1731 } 1732 iprot.Skip(ctx, thrift.STRUCT) 1733 iprot.ReadMessageEnd(ctx) 1734 x8 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) 1735 oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) 1736 x8.Write(ctx, oprot) 1737 oprot.WriteMessageEnd(ctx) 1738 oprot.Flush(ctx) 1739 return false, x8 1740 1741} 1742 1743type zipkinCollectorProcessorSubmitZipkinBatch struct { 1744 handler ZipkinCollector 1745} 1746 1747func (p *zipkinCollectorProcessorSubmitZipkinBatch) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { 1748 args := ZipkinCollectorSubmitZipkinBatchArgs{} 1749 var err2 error 1750 if err2 = args.Read(ctx, iprot); err2 != nil { 1751 iprot.ReadMessageEnd(ctx) 1752 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) 1753 oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.EXCEPTION, seqId) 1754 x.Write(ctx, oprot) 1755 oprot.WriteMessageEnd(ctx) 1756 oprot.Flush(ctx) 1757 return false, thrift.WrapTException(err2) 1758 } 1759 iprot.ReadMessageEnd(ctx) 1760 1761 tickerCancel := func() {} 1762 // Start a goroutine to do server side connectivity check. 1763 if thrift.ServerConnectivityCheckInterval > 0 { 1764 var cancel context.CancelFunc 1765 ctx, cancel = context.WithCancel(ctx) 1766 defer cancel() 1767 var tickerCtx context.Context 1768 tickerCtx, tickerCancel = context.WithCancel(context.Background()) 1769 defer tickerCancel() 1770 go func(ctx context.Context, cancel context.CancelFunc) { 1771 ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) 1772 defer ticker.Stop() 1773 for { 1774 select { 1775 case <-ctx.Done(): 1776 return 1777 case <-ticker.C: 1778 if !iprot.Transport().IsOpen() { 1779 cancel() 1780 return 1781 } 1782 } 1783 } 1784 }(tickerCtx, cancel) 1785 } 1786 1787 result := ZipkinCollectorSubmitZipkinBatchResult{} 1788 var retval []*Response 1789 if retval, err2 = p.handler.SubmitZipkinBatch(ctx, args.Spans); err2 != nil { 1790 tickerCancel() 1791 if err2 == thrift.ErrAbandonRequest { 1792 return false, thrift.WrapTException(err2) 1793 } 1794 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing submitZipkinBatch: "+err2.Error()) 1795 oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.EXCEPTION, seqId) 1796 x.Write(ctx, oprot) 1797 oprot.WriteMessageEnd(ctx) 1798 oprot.Flush(ctx) 1799 return true, thrift.WrapTException(err2) 1800 } else { 1801 result.Success = retval 1802 } 1803 tickerCancel() 1804 if err2 = oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.REPLY, seqId); err2 != nil { 1805 err = thrift.WrapTException(err2) 1806 } 1807 if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { 1808 err = thrift.WrapTException(err2) 1809 } 1810 if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { 1811 err = thrift.WrapTException(err2) 1812 } 1813 if err2 = oprot.Flush(ctx); err == nil && err2 != nil { 1814 err = thrift.WrapTException(err2) 1815 } 1816 if err != nil { 1817 return 1818 } 1819 return true, err 1820} 1821 1822// HELPER FUNCTIONS AND STRUCTURES 1823 1824// Attributes: 1825// - Spans 1826type ZipkinCollectorSubmitZipkinBatchArgs struct { 1827 Spans []*Span `thrift:"spans,1" db:"spans" json:"spans"` 1828} 1829 1830func NewZipkinCollectorSubmitZipkinBatchArgs() *ZipkinCollectorSubmitZipkinBatchArgs { 1831 return &ZipkinCollectorSubmitZipkinBatchArgs{} 1832} 1833 1834func (p *ZipkinCollectorSubmitZipkinBatchArgs) GetSpans() []*Span { 1835 return p.Spans 1836} 1837func (p *ZipkinCollectorSubmitZipkinBatchArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { 1838 if _, err := iprot.ReadStructBegin(ctx); err != nil { 1839 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 1840 } 1841 1842 for { 1843 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) 1844 if err != nil { 1845 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 1846 } 1847 if fieldTypeId == thrift.STOP { 1848 break 1849 } 1850 switch fieldId { 1851 case 1: 1852 if fieldTypeId == thrift.LIST { 1853 if err := p.ReadField1(ctx, iprot); err != nil { 1854 return err 1855 } 1856 } else { 1857 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1858 return err 1859 } 1860 } 1861 default: 1862 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1863 return err 1864 } 1865 } 1866 if err := iprot.ReadFieldEnd(ctx); err != nil { 1867 return err 1868 } 1869 } 1870 if err := iprot.ReadStructEnd(ctx); err != nil { 1871 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1872 } 1873 return nil 1874} 1875 1876func (p *ZipkinCollectorSubmitZipkinBatchArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { 1877 _, size, err := iprot.ReadListBegin(ctx) 1878 if err != nil { 1879 return thrift.PrependError("error reading list begin: ", err) 1880 } 1881 tSlice := make([]*Span, 0, size) 1882 p.Spans = tSlice 1883 for i := 0; i < size; i++ { 1884 _elem9 := &Span{} 1885 if err := _elem9.Read(ctx, iprot); err != nil { 1886 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem9), err) 1887 } 1888 p.Spans = append(p.Spans, _elem9) 1889 } 1890 if err := iprot.ReadListEnd(ctx); err != nil { 1891 return thrift.PrependError("error reading list end: ", err) 1892 } 1893 return nil 1894} 1895 1896func (p *ZipkinCollectorSubmitZipkinBatchArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { 1897 if err := oprot.WriteStructBegin(ctx, "submitZipkinBatch_args"); err != nil { 1898 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 1899 } 1900 if p != nil { 1901 if err := p.writeField1(ctx, oprot); err != nil { 1902 return err 1903 } 1904 } 1905 if err := oprot.WriteFieldStop(ctx); err != nil { 1906 return thrift.PrependError("write field stop error: ", err) 1907 } 1908 if err := oprot.WriteStructEnd(ctx); err != nil { 1909 return thrift.PrependError("write struct stop error: ", err) 1910 } 1911 return nil 1912} 1913 1914func (p *ZipkinCollectorSubmitZipkinBatchArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { 1915 if err := oprot.WriteFieldBegin(ctx, "spans", thrift.LIST, 1); err != nil { 1916 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:spans: ", p), err) 1917 } 1918 if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Spans)); err != nil { 1919 return thrift.PrependError("error writing list begin: ", err) 1920 } 1921 for _, v := range p.Spans { 1922 if err := v.Write(ctx, oprot); err != nil { 1923 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1924 } 1925 } 1926 if err := oprot.WriteListEnd(ctx); err != nil { 1927 return thrift.PrependError("error writing list end: ", err) 1928 } 1929 if err := oprot.WriteFieldEnd(ctx); err != nil { 1930 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:spans: ", p), err) 1931 } 1932 return err 1933} 1934 1935func (p *ZipkinCollectorSubmitZipkinBatchArgs) String() string { 1936 if p == nil { 1937 return "<nil>" 1938 } 1939 return fmt.Sprintf("ZipkinCollectorSubmitZipkinBatchArgs(%+v)", *p) 1940} 1941 1942// Attributes: 1943// - Success 1944type ZipkinCollectorSubmitZipkinBatchResult struct { 1945 Success []*Response `thrift:"success,0" db:"success" json:"success,omitempty"` 1946} 1947 1948func NewZipkinCollectorSubmitZipkinBatchResult() *ZipkinCollectorSubmitZipkinBatchResult { 1949 return &ZipkinCollectorSubmitZipkinBatchResult{} 1950} 1951 1952var ZipkinCollectorSubmitZipkinBatchResult_Success_DEFAULT []*Response 1953 1954func (p *ZipkinCollectorSubmitZipkinBatchResult) GetSuccess() []*Response { 1955 return p.Success 1956} 1957func (p *ZipkinCollectorSubmitZipkinBatchResult) IsSetSuccess() bool { 1958 return p.Success != nil 1959} 1960 1961func (p *ZipkinCollectorSubmitZipkinBatchResult) Read(ctx context.Context, iprot thrift.TProtocol) error { 1962 if _, err := iprot.ReadStructBegin(ctx); err != nil { 1963 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 1964 } 1965 1966 for { 1967 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) 1968 if err != nil { 1969 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 1970 } 1971 if fieldTypeId == thrift.STOP { 1972 break 1973 } 1974 switch fieldId { 1975 case 0: 1976 if fieldTypeId == thrift.LIST { 1977 if err := p.ReadField0(ctx, iprot); err != nil { 1978 return err 1979 } 1980 } else { 1981 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1982 return err 1983 } 1984 } 1985 default: 1986 if err := iprot.Skip(ctx, fieldTypeId); err != nil { 1987 return err 1988 } 1989 } 1990 if err := iprot.ReadFieldEnd(ctx); err != nil { 1991 return err 1992 } 1993 } 1994 if err := iprot.ReadStructEnd(ctx); err != nil { 1995 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1996 } 1997 return nil 1998} 1999 2000func (p *ZipkinCollectorSubmitZipkinBatchResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { 2001 _, size, err := iprot.ReadListBegin(ctx) 2002 if err != nil { 2003 return thrift.PrependError("error reading list begin: ", err) 2004 } 2005 tSlice := make([]*Response, 0, size) 2006 p.Success = tSlice 2007 for i := 0; i < size; i++ { 2008 _elem10 := &Response{} 2009 if err := _elem10.Read(ctx, iprot); err != nil { 2010 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem10), err) 2011 } 2012 p.Success = append(p.Success, _elem10) 2013 } 2014 if err := iprot.ReadListEnd(ctx); err != nil { 2015 return thrift.PrependError("error reading list end: ", err) 2016 } 2017 return nil 2018} 2019 2020func (p *ZipkinCollectorSubmitZipkinBatchResult) Write(ctx context.Context, oprot thrift.TProtocol) error { 2021 if err := oprot.WriteStructBegin(ctx, "submitZipkinBatch_result"); err != nil { 2022 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 2023 } 2024 if p != nil { 2025 if err := p.writeField0(ctx, oprot); err != nil { 2026 return err 2027 } 2028 } 2029 if err := oprot.WriteFieldStop(ctx); err != nil { 2030 return thrift.PrependError("write field stop error: ", err) 2031 } 2032 if err := oprot.WriteStructEnd(ctx); err != nil { 2033 return thrift.PrependError("write struct stop error: ", err) 2034 } 2035 return nil 2036} 2037 2038func (p *ZipkinCollectorSubmitZipkinBatchResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { 2039 if p.IsSetSuccess() { 2040 if err := oprot.WriteFieldBegin(ctx, "success", thrift.LIST, 0); err != nil { 2041 return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) 2042 } 2043 if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Success)); err != nil { 2044 return thrift.PrependError("error writing list begin: ", err) 2045 } 2046 for _, v := range p.Success { 2047 if err := v.Write(ctx, oprot); err != nil { 2048 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 2049 } 2050 } 2051 if err := oprot.WriteListEnd(ctx); err != nil { 2052 return thrift.PrependError("error writing list end: ", err) 2053 } 2054 if err := oprot.WriteFieldEnd(ctx); err != nil { 2055 return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) 2056 } 2057 } 2058 return err 2059} 2060 2061func (p *ZipkinCollectorSubmitZipkinBatchResult) String() string { 2062 if p == nil { 2063 return "<nil>" 2064 } 2065 return fmt.Sprintf("ZipkinCollectorSubmitZipkinBatchResult(%+v)", *p) 2066} 2067