Prince Pereira | c1c21d6 | 2021-04-22 08:38:15 +0000 | [diff] [blame^] | 1 | // Autogenerated by Thrift Compiler (0.9.3) |
| 2 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING |
| 3 | |
| 4 | package zipkincore |
| 5 | |
| 6 | import ( |
| 7 | "bytes" |
| 8 | "fmt" |
| 9 | "github.com/uber/jaeger-client-go/thrift" |
| 10 | ) |
| 11 | |
| 12 | // (needed to ensure safety because of naive import list construction.) |
| 13 | var _ = thrift.ZERO |
| 14 | var _ = fmt.Printf |
| 15 | var _ = bytes.Equal |
| 16 | |
| 17 | type ZipkinCollector interface { |
| 18 | // Parameters: |
| 19 | // - Spans |
| 20 | SubmitZipkinBatch(spans []*Span) (r []*Response, err error) |
| 21 | } |
| 22 | |
| 23 | type ZipkinCollectorClient struct { |
| 24 | Transport thrift.TTransport |
| 25 | ProtocolFactory thrift.TProtocolFactory |
| 26 | InputProtocol thrift.TProtocol |
| 27 | OutputProtocol thrift.TProtocol |
| 28 | SeqId int32 |
| 29 | } |
| 30 | |
| 31 | func NewZipkinCollectorClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ZipkinCollectorClient { |
| 32 | return &ZipkinCollectorClient{Transport: t, |
| 33 | ProtocolFactory: f, |
| 34 | InputProtocol: f.GetProtocol(t), |
| 35 | OutputProtocol: f.GetProtocol(t), |
| 36 | SeqId: 0, |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func NewZipkinCollectorClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ZipkinCollectorClient { |
| 41 | return &ZipkinCollectorClient{Transport: t, |
| 42 | ProtocolFactory: nil, |
| 43 | InputProtocol: iprot, |
| 44 | OutputProtocol: oprot, |
| 45 | SeqId: 0, |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // Parameters: |
| 50 | // - Spans |
| 51 | func (p *ZipkinCollectorClient) SubmitZipkinBatch(spans []*Span) (r []*Response, err error) { |
| 52 | if err = p.sendSubmitZipkinBatch(spans); err != nil { |
| 53 | return |
| 54 | } |
| 55 | return p.recvSubmitZipkinBatch() |
| 56 | } |
| 57 | |
| 58 | func (p *ZipkinCollectorClient) sendSubmitZipkinBatch(spans []*Span) (err error) { |
| 59 | oprot := p.OutputProtocol |
| 60 | if oprot == nil { |
| 61 | oprot = p.ProtocolFactory.GetProtocol(p.Transport) |
| 62 | p.OutputProtocol = oprot |
| 63 | } |
| 64 | p.SeqId++ |
| 65 | if err = oprot.WriteMessageBegin("submitZipkinBatch", thrift.CALL, p.SeqId); err != nil { |
| 66 | return |
| 67 | } |
| 68 | args := ZipkinCollectorSubmitZipkinBatchArgs{ |
| 69 | Spans: spans, |
| 70 | } |
| 71 | if err = args.Write(oprot); err != nil { |
| 72 | return |
| 73 | } |
| 74 | if err = oprot.WriteMessageEnd(); err != nil { |
| 75 | return |
| 76 | } |
| 77 | return oprot.Flush() |
| 78 | } |
| 79 | |
| 80 | func (p *ZipkinCollectorClient) recvSubmitZipkinBatch() (value []*Response, err error) { |
| 81 | iprot := p.InputProtocol |
| 82 | if iprot == nil { |
| 83 | iprot = p.ProtocolFactory.GetProtocol(p.Transport) |
| 84 | p.InputProtocol = iprot |
| 85 | } |
| 86 | method, mTypeId, seqId, err := iprot.ReadMessageBegin() |
| 87 | if err != nil { |
| 88 | return |
| 89 | } |
| 90 | if method != "submitZipkinBatch" { |
| 91 | err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "submitZipkinBatch failed: wrong method name") |
| 92 | return |
| 93 | } |
| 94 | if p.SeqId != seqId { |
| 95 | err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "submitZipkinBatch failed: out of sequence response") |
| 96 | return |
| 97 | } |
| 98 | if mTypeId == thrift.EXCEPTION { |
| 99 | error2 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") |
| 100 | var error3 error |
| 101 | error3, err = error2.Read(iprot) |
| 102 | if err != nil { |
| 103 | return |
| 104 | } |
| 105 | if err = iprot.ReadMessageEnd(); err != nil { |
| 106 | return |
| 107 | } |
| 108 | err = error3 |
| 109 | return |
| 110 | } |
| 111 | if mTypeId != thrift.REPLY { |
| 112 | err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "submitZipkinBatch failed: invalid message type") |
| 113 | return |
| 114 | } |
| 115 | result := ZipkinCollectorSubmitZipkinBatchResult{} |
| 116 | if err = result.Read(iprot); err != nil { |
| 117 | return |
| 118 | } |
| 119 | if err = iprot.ReadMessageEnd(); err != nil { |
| 120 | return |
| 121 | } |
| 122 | value = result.GetSuccess() |
| 123 | return |
| 124 | } |
| 125 | |
| 126 | type ZipkinCollectorProcessor struct { |
| 127 | processorMap map[string]thrift.TProcessorFunction |
| 128 | handler ZipkinCollector |
| 129 | } |
| 130 | |
| 131 | func (p *ZipkinCollectorProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { |
| 132 | p.processorMap[key] = processor |
| 133 | } |
| 134 | |
| 135 | func (p *ZipkinCollectorProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { |
| 136 | processor, ok = p.processorMap[key] |
| 137 | return processor, ok |
| 138 | } |
| 139 | |
| 140 | func (p *ZipkinCollectorProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { |
| 141 | return p.processorMap |
| 142 | } |
| 143 | |
| 144 | func NewZipkinCollectorProcessor(handler ZipkinCollector) *ZipkinCollectorProcessor { |
| 145 | |
| 146 | self4 := &ZipkinCollectorProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} |
| 147 | self4.processorMap["submitZipkinBatch"] = &zipkinCollectorProcessorSubmitZipkinBatch{handler: handler} |
| 148 | return self4 |
| 149 | } |
| 150 | |
| 151 | func (p *ZipkinCollectorProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { |
| 152 | name, _, seqId, err := iprot.ReadMessageBegin() |
| 153 | if err != nil { |
| 154 | return false, err |
| 155 | } |
| 156 | if processor, ok := p.GetProcessorFunction(name); ok { |
| 157 | return processor.Process(seqId, iprot, oprot) |
| 158 | } |
| 159 | iprot.Skip(thrift.STRUCT) |
| 160 | iprot.ReadMessageEnd() |
| 161 | x5 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) |
| 162 | oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) |
| 163 | x5.Write(oprot) |
| 164 | oprot.WriteMessageEnd() |
| 165 | oprot.Flush() |
| 166 | return false, x5 |
| 167 | |
| 168 | } |
| 169 | |
| 170 | type zipkinCollectorProcessorSubmitZipkinBatch struct { |
| 171 | handler ZipkinCollector |
| 172 | } |
| 173 | |
| 174 | func (p *zipkinCollectorProcessorSubmitZipkinBatch) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { |
| 175 | args := ZipkinCollectorSubmitZipkinBatchArgs{} |
| 176 | if err = args.Read(iprot); err != nil { |
| 177 | iprot.ReadMessageEnd() |
| 178 | x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) |
| 179 | oprot.WriteMessageBegin("submitZipkinBatch", thrift.EXCEPTION, seqId) |
| 180 | x.Write(oprot) |
| 181 | oprot.WriteMessageEnd() |
| 182 | oprot.Flush() |
| 183 | return false, err |
| 184 | } |
| 185 | |
| 186 | iprot.ReadMessageEnd() |
| 187 | result := ZipkinCollectorSubmitZipkinBatchResult{} |
| 188 | var retval []*Response |
| 189 | var err2 error |
| 190 | if retval, err2 = p.handler.SubmitZipkinBatch(args.Spans); err2 != nil { |
| 191 | x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing submitZipkinBatch: "+err2.Error()) |
| 192 | oprot.WriteMessageBegin("submitZipkinBatch", thrift.EXCEPTION, seqId) |
| 193 | x.Write(oprot) |
| 194 | oprot.WriteMessageEnd() |
| 195 | oprot.Flush() |
| 196 | return true, err2 |
| 197 | } else { |
| 198 | result.Success = retval |
| 199 | } |
| 200 | if err2 = oprot.WriteMessageBegin("submitZipkinBatch", thrift.REPLY, seqId); err2 != nil { |
| 201 | err = err2 |
| 202 | } |
| 203 | if err2 = result.Write(oprot); err == nil && err2 != nil { |
| 204 | err = err2 |
| 205 | } |
| 206 | if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { |
| 207 | err = err2 |
| 208 | } |
| 209 | if err2 = oprot.Flush(); err == nil && err2 != nil { |
| 210 | err = err2 |
| 211 | } |
| 212 | if err != nil { |
| 213 | return |
| 214 | } |
| 215 | return true, err |
| 216 | } |
| 217 | |
| 218 | // HELPER FUNCTIONS AND STRUCTURES |
| 219 | |
| 220 | // Attributes: |
| 221 | // - Spans |
| 222 | type ZipkinCollectorSubmitZipkinBatchArgs struct { |
| 223 | Spans []*Span `thrift:"spans,1" json:"spans"` |
| 224 | } |
| 225 | |
| 226 | func NewZipkinCollectorSubmitZipkinBatchArgs() *ZipkinCollectorSubmitZipkinBatchArgs { |
| 227 | return &ZipkinCollectorSubmitZipkinBatchArgs{} |
| 228 | } |
| 229 | |
| 230 | func (p *ZipkinCollectorSubmitZipkinBatchArgs) GetSpans() []*Span { |
| 231 | return p.Spans |
| 232 | } |
| 233 | func (p *ZipkinCollectorSubmitZipkinBatchArgs) Read(iprot thrift.TProtocol) error { |
| 234 | if _, err := iprot.ReadStructBegin(); err != nil { |
| 235 | return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) |
| 236 | } |
| 237 | |
| 238 | for { |
| 239 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() |
| 240 | if err != nil { |
| 241 | return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) |
| 242 | } |
| 243 | if fieldTypeId == thrift.STOP { |
| 244 | break |
| 245 | } |
| 246 | switch fieldId { |
| 247 | case 1: |
| 248 | if err := p.readField1(iprot); err != nil { |
| 249 | return err |
| 250 | } |
| 251 | default: |
| 252 | if err := iprot.Skip(fieldTypeId); err != nil { |
| 253 | return err |
| 254 | } |
| 255 | } |
| 256 | if err := iprot.ReadFieldEnd(); err != nil { |
| 257 | return err |
| 258 | } |
| 259 | } |
| 260 | if err := iprot.ReadStructEnd(); err != nil { |
| 261 | return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) |
| 262 | } |
| 263 | return nil |
| 264 | } |
| 265 | |
| 266 | func (p *ZipkinCollectorSubmitZipkinBatchArgs) readField1(iprot thrift.TProtocol) error { |
| 267 | _, size, err := iprot.ReadListBegin() |
| 268 | if err != nil { |
| 269 | return thrift.PrependError("error reading list begin: ", err) |
| 270 | } |
| 271 | tSlice := make([]*Span, 0, size) |
| 272 | p.Spans = tSlice |
| 273 | for i := 0; i < size; i++ { |
| 274 | _elem6 := &Span{} |
| 275 | if err := _elem6.Read(iprot); err != nil { |
| 276 | return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem6), err) |
| 277 | } |
| 278 | p.Spans = append(p.Spans, _elem6) |
| 279 | } |
| 280 | if err := iprot.ReadListEnd(); err != nil { |
| 281 | return thrift.PrependError("error reading list end: ", err) |
| 282 | } |
| 283 | return nil |
| 284 | } |
| 285 | |
| 286 | func (p *ZipkinCollectorSubmitZipkinBatchArgs) Write(oprot thrift.TProtocol) error { |
| 287 | if err := oprot.WriteStructBegin("submitZipkinBatch_args"); err != nil { |
| 288 | return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) |
| 289 | } |
| 290 | if err := p.writeField1(oprot); err != nil { |
| 291 | return err |
| 292 | } |
| 293 | if err := oprot.WriteFieldStop(); err != nil { |
| 294 | return thrift.PrependError("write field stop error: ", err) |
| 295 | } |
| 296 | if err := oprot.WriteStructEnd(); err != nil { |
| 297 | return thrift.PrependError("write struct stop error: ", err) |
| 298 | } |
| 299 | return nil |
| 300 | } |
| 301 | |
| 302 | func (p *ZipkinCollectorSubmitZipkinBatchArgs) writeField1(oprot thrift.TProtocol) (err error) { |
| 303 | if err := oprot.WriteFieldBegin("spans", thrift.LIST, 1); err != nil { |
| 304 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:spans: ", p), err) |
| 305 | } |
| 306 | if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Spans)); err != nil { |
| 307 | return thrift.PrependError("error writing list begin: ", err) |
| 308 | } |
| 309 | for _, v := range p.Spans { |
| 310 | if err := v.Write(oprot); err != nil { |
| 311 | return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) |
| 312 | } |
| 313 | } |
| 314 | if err := oprot.WriteListEnd(); err != nil { |
| 315 | return thrift.PrependError("error writing list end: ", err) |
| 316 | } |
| 317 | if err := oprot.WriteFieldEnd(); err != nil { |
| 318 | return thrift.PrependError(fmt.Sprintf("%T write field end error 1:spans: ", p), err) |
| 319 | } |
| 320 | return err |
| 321 | } |
| 322 | |
| 323 | func (p *ZipkinCollectorSubmitZipkinBatchArgs) String() string { |
| 324 | if p == nil { |
| 325 | return "<nil>" |
| 326 | } |
| 327 | return fmt.Sprintf("ZipkinCollectorSubmitZipkinBatchArgs(%+v)", *p) |
| 328 | } |
| 329 | |
| 330 | // Attributes: |
| 331 | // - Success |
| 332 | type ZipkinCollectorSubmitZipkinBatchResult struct { |
| 333 | Success []*Response `thrift:"success,0" json:"success,omitempty"` |
| 334 | } |
| 335 | |
| 336 | func NewZipkinCollectorSubmitZipkinBatchResult() *ZipkinCollectorSubmitZipkinBatchResult { |
| 337 | return &ZipkinCollectorSubmitZipkinBatchResult{} |
| 338 | } |
| 339 | |
| 340 | var ZipkinCollectorSubmitZipkinBatchResult_Success_DEFAULT []*Response |
| 341 | |
| 342 | func (p *ZipkinCollectorSubmitZipkinBatchResult) GetSuccess() []*Response { |
| 343 | return p.Success |
| 344 | } |
| 345 | func (p *ZipkinCollectorSubmitZipkinBatchResult) IsSetSuccess() bool { |
| 346 | return p.Success != nil |
| 347 | } |
| 348 | |
| 349 | func (p *ZipkinCollectorSubmitZipkinBatchResult) Read(iprot thrift.TProtocol) error { |
| 350 | if _, err := iprot.ReadStructBegin(); err != nil { |
| 351 | return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) |
| 352 | } |
| 353 | |
| 354 | for { |
| 355 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() |
| 356 | if err != nil { |
| 357 | return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) |
| 358 | } |
| 359 | if fieldTypeId == thrift.STOP { |
| 360 | break |
| 361 | } |
| 362 | switch fieldId { |
| 363 | case 0: |
| 364 | if err := p.readField0(iprot); err != nil { |
| 365 | return err |
| 366 | } |
| 367 | default: |
| 368 | if err := iprot.Skip(fieldTypeId); err != nil { |
| 369 | return err |
| 370 | } |
| 371 | } |
| 372 | if err := iprot.ReadFieldEnd(); err != nil { |
| 373 | return err |
| 374 | } |
| 375 | } |
| 376 | if err := iprot.ReadStructEnd(); err != nil { |
| 377 | return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) |
| 378 | } |
| 379 | return nil |
| 380 | } |
| 381 | |
| 382 | func (p *ZipkinCollectorSubmitZipkinBatchResult) readField0(iprot thrift.TProtocol) error { |
| 383 | _, size, err := iprot.ReadListBegin() |
| 384 | if err != nil { |
| 385 | return thrift.PrependError("error reading list begin: ", err) |
| 386 | } |
| 387 | tSlice := make([]*Response, 0, size) |
| 388 | p.Success = tSlice |
| 389 | for i := 0; i < size; i++ { |
| 390 | _elem7 := &Response{} |
| 391 | if err := _elem7.Read(iprot); err != nil { |
| 392 | return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem7), err) |
| 393 | } |
| 394 | p.Success = append(p.Success, _elem7) |
| 395 | } |
| 396 | if err := iprot.ReadListEnd(); err != nil { |
| 397 | return thrift.PrependError("error reading list end: ", err) |
| 398 | } |
| 399 | return nil |
| 400 | } |
| 401 | |
| 402 | func (p *ZipkinCollectorSubmitZipkinBatchResult) Write(oprot thrift.TProtocol) error { |
| 403 | if err := oprot.WriteStructBegin("submitZipkinBatch_result"); err != nil { |
| 404 | return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) |
| 405 | } |
| 406 | if err := p.writeField0(oprot); err != nil { |
| 407 | return err |
| 408 | } |
| 409 | if err := oprot.WriteFieldStop(); err != nil { |
| 410 | return thrift.PrependError("write field stop error: ", err) |
| 411 | } |
| 412 | if err := oprot.WriteStructEnd(); err != nil { |
| 413 | return thrift.PrependError("write struct stop error: ", err) |
| 414 | } |
| 415 | return nil |
| 416 | } |
| 417 | |
| 418 | func (p *ZipkinCollectorSubmitZipkinBatchResult) writeField0(oprot thrift.TProtocol) (err error) { |
| 419 | if p.IsSetSuccess() { |
| 420 | if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { |
| 421 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) |
| 422 | } |
| 423 | if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil { |
| 424 | return thrift.PrependError("error writing list begin: ", err) |
| 425 | } |
| 426 | for _, v := range p.Success { |
| 427 | if err := v.Write(oprot); err != nil { |
| 428 | return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) |
| 429 | } |
| 430 | } |
| 431 | if err := oprot.WriteListEnd(); err != nil { |
| 432 | return thrift.PrependError("error writing list end: ", err) |
| 433 | } |
| 434 | if err := oprot.WriteFieldEnd(); err != nil { |
| 435 | return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) |
| 436 | } |
| 437 | } |
| 438 | return err |
| 439 | } |
| 440 | |
| 441 | func (p *ZipkinCollectorSubmitZipkinBatchResult) String() string { |
| 442 | if p == nil { |
| 443 | return "<nil>" |
| 444 | } |
| 445 | return fmt.Sprintf("ZipkinCollectorSubmitZipkinBatchResult(%+v)", *p) |
| 446 | } |