Girish Kumar | e48ec8a | 2020-08-18 12:28:51 +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 agent |
| 5 | |
| 6 | import ( |
| 7 | "bytes" |
| 8 | "fmt" |
| 9 | "github.com/uber/jaeger-client-go/thrift" |
| 10 | "github.com/uber/jaeger-client-go/thrift-gen/jaeger" |
| 11 | "github.com/uber/jaeger-client-go/thrift-gen/zipkincore" |
| 12 | ) |
| 13 | |
| 14 | // (needed to ensure safety because of naive import list construction.) |
| 15 | var _ = thrift.ZERO |
| 16 | var _ = fmt.Printf |
| 17 | var _ = bytes.Equal |
| 18 | |
| 19 | var _ = jaeger.GoUnusedProtection__ |
| 20 | var _ = zipkincore.GoUnusedProtection__ |
| 21 | |
| 22 | type Agent interface { |
| 23 | // Parameters: |
| 24 | // - Spans |
| 25 | EmitZipkinBatch(spans []*zipkincore.Span) (err error) |
| 26 | // Parameters: |
| 27 | // - Batch |
| 28 | EmitBatch(batch *jaeger.Batch) (err error) |
| 29 | } |
| 30 | |
| 31 | type AgentClient struct { |
| 32 | Transport thrift.TTransport |
| 33 | ProtocolFactory thrift.TProtocolFactory |
| 34 | InputProtocol thrift.TProtocol |
| 35 | OutputProtocol thrift.TProtocol |
| 36 | SeqId int32 |
| 37 | } |
| 38 | |
| 39 | func NewAgentClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AgentClient { |
| 40 | return &AgentClient{Transport: t, |
| 41 | ProtocolFactory: f, |
| 42 | InputProtocol: f.GetProtocol(t), |
| 43 | OutputProtocol: f.GetProtocol(t), |
| 44 | SeqId: 0, |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func NewAgentClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AgentClient { |
| 49 | return &AgentClient{Transport: t, |
| 50 | ProtocolFactory: nil, |
| 51 | InputProtocol: iprot, |
| 52 | OutputProtocol: oprot, |
| 53 | SeqId: 0, |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // Parameters: |
| 58 | // - Spans |
| 59 | func (p *AgentClient) EmitZipkinBatch(spans []*zipkincore.Span) (err error) { |
| 60 | if err = p.sendEmitZipkinBatch(spans); err != nil { |
| 61 | return |
| 62 | } |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | func (p *AgentClient) sendEmitZipkinBatch(spans []*zipkincore.Span) (err error) { |
| 67 | oprot := p.OutputProtocol |
| 68 | if oprot == nil { |
| 69 | oprot = p.ProtocolFactory.GetProtocol(p.Transport) |
| 70 | p.OutputProtocol = oprot |
| 71 | } |
| 72 | p.SeqId++ |
| 73 | if err = oprot.WriteMessageBegin("emitZipkinBatch", thrift.ONEWAY, p.SeqId); err != nil { |
| 74 | return |
| 75 | } |
| 76 | args := AgentEmitZipkinBatchArgs{ |
| 77 | Spans: spans, |
| 78 | } |
| 79 | if err = args.Write(oprot); err != nil { |
| 80 | return |
| 81 | } |
| 82 | if err = oprot.WriteMessageEnd(); err != nil { |
| 83 | return |
| 84 | } |
| 85 | return oprot.Flush() |
| 86 | } |
| 87 | |
| 88 | // Parameters: |
| 89 | // - Batch |
| 90 | func (p *AgentClient) EmitBatch(batch *jaeger.Batch) (err error) { |
| 91 | if err = p.sendEmitBatch(batch); err != nil { |
| 92 | return |
| 93 | } |
| 94 | return |
| 95 | } |
| 96 | |
| 97 | func (p *AgentClient) sendEmitBatch(batch *jaeger.Batch) (err error) { |
| 98 | oprot := p.OutputProtocol |
| 99 | if oprot == nil { |
| 100 | oprot = p.ProtocolFactory.GetProtocol(p.Transport) |
| 101 | p.OutputProtocol = oprot |
| 102 | } |
| 103 | p.SeqId++ |
| 104 | if err = oprot.WriteMessageBegin("emitBatch", thrift.ONEWAY, p.SeqId); err != nil { |
| 105 | return |
| 106 | } |
| 107 | args := AgentEmitBatchArgs{ |
| 108 | Batch: batch, |
| 109 | } |
| 110 | if err = args.Write(oprot); err != nil { |
| 111 | return |
| 112 | } |
| 113 | if err = oprot.WriteMessageEnd(); err != nil { |
| 114 | return |
| 115 | } |
| 116 | return oprot.Flush() |
| 117 | } |
| 118 | |
| 119 | type AgentProcessor struct { |
| 120 | processorMap map[string]thrift.TProcessorFunction |
| 121 | handler Agent |
| 122 | } |
| 123 | |
| 124 | func (p *AgentProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { |
| 125 | p.processorMap[key] = processor |
| 126 | } |
| 127 | |
| 128 | func (p *AgentProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { |
| 129 | processor, ok = p.processorMap[key] |
| 130 | return processor, ok |
| 131 | } |
| 132 | |
| 133 | func (p *AgentProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { |
| 134 | return p.processorMap |
| 135 | } |
| 136 | |
| 137 | func NewAgentProcessor(handler Agent) *AgentProcessor { |
| 138 | |
| 139 | self0 := &AgentProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} |
| 140 | self0.processorMap["emitZipkinBatch"] = &agentProcessorEmitZipkinBatch{handler: handler} |
| 141 | self0.processorMap["emitBatch"] = &agentProcessorEmitBatch{handler: handler} |
| 142 | return self0 |
| 143 | } |
| 144 | |
| 145 | func (p *AgentProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { |
| 146 | name, _, seqId, err := iprot.ReadMessageBegin() |
| 147 | if err != nil { |
| 148 | return false, err |
| 149 | } |
| 150 | if processor, ok := p.GetProcessorFunction(name); ok { |
| 151 | return processor.Process(seqId, iprot, oprot) |
| 152 | } |
| 153 | iprot.Skip(thrift.STRUCT) |
| 154 | iprot.ReadMessageEnd() |
| 155 | x1 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) |
| 156 | oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) |
| 157 | x1.Write(oprot) |
| 158 | oprot.WriteMessageEnd() |
| 159 | oprot.Flush() |
| 160 | return false, x1 |
| 161 | |
| 162 | } |
| 163 | |
| 164 | type agentProcessorEmitZipkinBatch struct { |
| 165 | handler Agent |
| 166 | } |
| 167 | |
| 168 | func (p *agentProcessorEmitZipkinBatch) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { |
| 169 | args := AgentEmitZipkinBatchArgs{} |
| 170 | if err = args.Read(iprot); err != nil { |
| 171 | iprot.ReadMessageEnd() |
| 172 | return false, err |
| 173 | } |
| 174 | |
| 175 | iprot.ReadMessageEnd() |
| 176 | var err2 error |
| 177 | if err2 = p.handler.EmitZipkinBatch(args.Spans); err2 != nil { |
| 178 | return true, err2 |
| 179 | } |
| 180 | return true, nil |
| 181 | } |
| 182 | |
| 183 | type agentProcessorEmitBatch struct { |
| 184 | handler Agent |
| 185 | } |
| 186 | |
| 187 | func (p *agentProcessorEmitBatch) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { |
| 188 | args := AgentEmitBatchArgs{} |
| 189 | if err = args.Read(iprot); err != nil { |
| 190 | iprot.ReadMessageEnd() |
| 191 | return false, err |
| 192 | } |
| 193 | |
| 194 | iprot.ReadMessageEnd() |
| 195 | var err2 error |
| 196 | if err2 = p.handler.EmitBatch(args.Batch); err2 != nil { |
| 197 | return true, err2 |
| 198 | } |
| 199 | return true, nil |
| 200 | } |
| 201 | |
| 202 | // HELPER FUNCTIONS AND STRUCTURES |
| 203 | |
| 204 | // Attributes: |
| 205 | // - Spans |
| 206 | type AgentEmitZipkinBatchArgs struct { |
| 207 | Spans []*zipkincore.Span `thrift:"spans,1" json:"spans"` |
| 208 | } |
| 209 | |
| 210 | func NewAgentEmitZipkinBatchArgs() *AgentEmitZipkinBatchArgs { |
| 211 | return &AgentEmitZipkinBatchArgs{} |
| 212 | } |
| 213 | |
| 214 | func (p *AgentEmitZipkinBatchArgs) GetSpans() []*zipkincore.Span { |
| 215 | return p.Spans |
| 216 | } |
| 217 | func (p *AgentEmitZipkinBatchArgs) Read(iprot thrift.TProtocol) error { |
| 218 | if _, err := iprot.ReadStructBegin(); err != nil { |
| 219 | return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) |
| 220 | } |
| 221 | |
| 222 | for { |
| 223 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() |
| 224 | if err != nil { |
| 225 | return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) |
| 226 | } |
| 227 | if fieldTypeId == thrift.STOP { |
| 228 | break |
| 229 | } |
| 230 | switch fieldId { |
| 231 | case 1: |
| 232 | if err := p.readField1(iprot); err != nil { |
| 233 | return err |
| 234 | } |
| 235 | default: |
| 236 | if err := iprot.Skip(fieldTypeId); err != nil { |
| 237 | return err |
| 238 | } |
| 239 | } |
| 240 | if err := iprot.ReadFieldEnd(); err != nil { |
| 241 | return err |
| 242 | } |
| 243 | } |
| 244 | if err := iprot.ReadStructEnd(); err != nil { |
| 245 | return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) |
| 246 | } |
| 247 | return nil |
| 248 | } |
| 249 | |
| 250 | func (p *AgentEmitZipkinBatchArgs) readField1(iprot thrift.TProtocol) error { |
| 251 | _, size, err := iprot.ReadListBegin() |
| 252 | if err != nil { |
| 253 | return thrift.PrependError("error reading list begin: ", err) |
| 254 | } |
| 255 | tSlice := make([]*zipkincore.Span, 0, size) |
| 256 | p.Spans = tSlice |
| 257 | for i := 0; i < size; i++ { |
| 258 | _elem2 := &zipkincore.Span{} |
| 259 | if err := _elem2.Read(iprot); err != nil { |
| 260 | return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem2), err) |
| 261 | } |
| 262 | p.Spans = append(p.Spans, _elem2) |
| 263 | } |
| 264 | if err := iprot.ReadListEnd(); err != nil { |
| 265 | return thrift.PrependError("error reading list end: ", err) |
| 266 | } |
| 267 | return nil |
| 268 | } |
| 269 | |
| 270 | func (p *AgentEmitZipkinBatchArgs) Write(oprot thrift.TProtocol) error { |
| 271 | if err := oprot.WriteStructBegin("emitZipkinBatch_args"); err != nil { |
| 272 | return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) |
| 273 | } |
| 274 | if err := p.writeField1(oprot); err != nil { |
| 275 | return err |
| 276 | } |
| 277 | if err := oprot.WriteFieldStop(); err != nil { |
| 278 | return thrift.PrependError("write field stop error: ", err) |
| 279 | } |
| 280 | if err := oprot.WriteStructEnd(); err != nil { |
| 281 | return thrift.PrependError("write struct stop error: ", err) |
| 282 | } |
| 283 | return nil |
| 284 | } |
| 285 | |
| 286 | func (p *AgentEmitZipkinBatchArgs) writeField1(oprot thrift.TProtocol) (err error) { |
| 287 | if err := oprot.WriteFieldBegin("spans", thrift.LIST, 1); err != nil { |
| 288 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:spans: ", p), err) |
| 289 | } |
| 290 | if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Spans)); err != nil { |
| 291 | return thrift.PrependError("error writing list begin: ", err) |
| 292 | } |
| 293 | for _, v := range p.Spans { |
| 294 | if err := v.Write(oprot); err != nil { |
| 295 | return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) |
| 296 | } |
| 297 | } |
| 298 | if err := oprot.WriteListEnd(); err != nil { |
| 299 | return thrift.PrependError("error writing list end: ", err) |
| 300 | } |
| 301 | if err := oprot.WriteFieldEnd(); err != nil { |
| 302 | return thrift.PrependError(fmt.Sprintf("%T write field end error 1:spans: ", p), err) |
| 303 | } |
| 304 | return err |
| 305 | } |
| 306 | |
| 307 | func (p *AgentEmitZipkinBatchArgs) String() string { |
| 308 | if p == nil { |
| 309 | return "<nil>" |
| 310 | } |
| 311 | return fmt.Sprintf("AgentEmitZipkinBatchArgs(%+v)", *p) |
| 312 | } |
| 313 | |
| 314 | // Attributes: |
| 315 | // - Batch |
| 316 | type AgentEmitBatchArgs struct { |
| 317 | Batch *jaeger.Batch `thrift:"batch,1" json:"batch"` |
| 318 | } |
| 319 | |
| 320 | func NewAgentEmitBatchArgs() *AgentEmitBatchArgs { |
| 321 | return &AgentEmitBatchArgs{} |
| 322 | } |
| 323 | |
| 324 | var AgentEmitBatchArgs_Batch_DEFAULT *jaeger.Batch |
| 325 | |
| 326 | func (p *AgentEmitBatchArgs) GetBatch() *jaeger.Batch { |
| 327 | if !p.IsSetBatch() { |
| 328 | return AgentEmitBatchArgs_Batch_DEFAULT |
| 329 | } |
| 330 | return p.Batch |
| 331 | } |
| 332 | func (p *AgentEmitBatchArgs) IsSetBatch() bool { |
| 333 | return p.Batch != nil |
| 334 | } |
| 335 | |
| 336 | func (p *AgentEmitBatchArgs) Read(iprot thrift.TProtocol) error { |
| 337 | if _, err := iprot.ReadStructBegin(); err != nil { |
| 338 | return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) |
| 339 | } |
| 340 | |
| 341 | for { |
| 342 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() |
| 343 | if err != nil { |
| 344 | return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) |
| 345 | } |
| 346 | if fieldTypeId == thrift.STOP { |
| 347 | break |
| 348 | } |
| 349 | switch fieldId { |
| 350 | case 1: |
| 351 | if err := p.readField1(iprot); err != nil { |
| 352 | return err |
| 353 | } |
| 354 | default: |
| 355 | if err := iprot.Skip(fieldTypeId); err != nil { |
| 356 | return err |
| 357 | } |
| 358 | } |
| 359 | if err := iprot.ReadFieldEnd(); err != nil { |
| 360 | return err |
| 361 | } |
| 362 | } |
| 363 | if err := iprot.ReadStructEnd(); err != nil { |
| 364 | return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) |
| 365 | } |
| 366 | return nil |
| 367 | } |
| 368 | |
| 369 | func (p *AgentEmitBatchArgs) readField1(iprot thrift.TProtocol) error { |
| 370 | p.Batch = &jaeger.Batch{} |
| 371 | if err := p.Batch.Read(iprot); err != nil { |
| 372 | return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Batch), err) |
| 373 | } |
| 374 | return nil |
| 375 | } |
| 376 | |
| 377 | func (p *AgentEmitBatchArgs) Write(oprot thrift.TProtocol) error { |
| 378 | if err := oprot.WriteStructBegin("emitBatch_args"); err != nil { |
| 379 | return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) |
| 380 | } |
| 381 | if err := p.writeField1(oprot); err != nil { |
| 382 | return err |
| 383 | } |
| 384 | if err := oprot.WriteFieldStop(); err != nil { |
| 385 | return thrift.PrependError("write field stop error: ", err) |
| 386 | } |
| 387 | if err := oprot.WriteStructEnd(); err != nil { |
| 388 | return thrift.PrependError("write struct stop error: ", err) |
| 389 | } |
| 390 | return nil |
| 391 | } |
| 392 | |
| 393 | func (p *AgentEmitBatchArgs) writeField1(oprot thrift.TProtocol) (err error) { |
| 394 | if err := oprot.WriteFieldBegin("batch", thrift.STRUCT, 1); err != nil { |
| 395 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:batch: ", p), err) |
| 396 | } |
| 397 | if err := p.Batch.Write(oprot); err != nil { |
| 398 | return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Batch), err) |
| 399 | } |
| 400 | if err := oprot.WriteFieldEnd(); err != nil { |
| 401 | return thrift.PrependError(fmt.Sprintf("%T write field end error 1:batch: ", p), err) |
| 402 | } |
| 403 | return err |
| 404 | } |
| 405 | |
| 406 | func (p *AgentEmitBatchArgs) String() string { |
| 407 | if p == nil { |
| 408 | return "<nil>" |
| 409 | } |
| 410 | return fmt.Sprintf("AgentEmitBatchArgs(%+v)", *p) |
| 411 | } |