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