1// Autogenerated by Thrift Compiler (0.9.3)
2// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
3
4package jaeger
5
6import (
7	"bytes"
8	"context"
9	"fmt"
10
11	"github.com/apache/thrift/lib/go/thrift"
12)
13
14// (needed to ensure safety because of naive import list construction.)
15var _ = thrift.ZERO
16var _ = fmt.Printf
17var _ = bytes.Equal
18
19type Agent interface {
20	// Parameters:
21	//  - Batch
22	EmitBatch(batch *Batch) (err error)
23}
24
25type AgentClient struct {
26	Transport       thrift.TTransport
27	ProtocolFactory thrift.TProtocolFactory
28	InputProtocol   thrift.TProtocol
29	OutputProtocol  thrift.TProtocol
30	SeqId           int32
31}
32
33func NewAgentClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AgentClient {
34	return &AgentClient{Transport: t,
35		ProtocolFactory: f,
36		InputProtocol:   f.GetProtocol(t),
37		OutputProtocol:  f.GetProtocol(t),
38		SeqId:           0,
39	}
40}
41
42func NewAgentClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AgentClient {
43	return &AgentClient{Transport: t,
44		ProtocolFactory: nil,
45		InputProtocol:   iprot,
46		OutputProtocol:  oprot,
47		SeqId:           0,
48	}
49}
50
51// Parameters:
52//  - Batch
53func (p *AgentClient) EmitBatch(batch *Batch) (err error) {
54	if err = p.sendEmitBatch(batch); err != nil {
55		return
56	}
57	return
58}
59
60func (p *AgentClient) sendEmitBatch(batch *Batch) (err error) {
61	oprot := p.OutputProtocol
62	if oprot == nil {
63		oprot = p.ProtocolFactory.GetProtocol(p.Transport)
64		p.OutputProtocol = oprot
65	}
66	p.SeqId++
67	if err = oprot.WriteMessageBegin("emitBatch", thrift.ONEWAY, p.SeqId); err != nil {
68		return
69	}
70	args := AgentEmitBatchArgs{
71		Batch: batch,
72	}
73	if err = args.Write(oprot); err != nil {
74		return
75	}
76	if err = oprot.WriteMessageEnd(); err != nil {
77		return
78	}
79	return oprot.Flush(context.Background())
80}
81
82type AgentProcessor struct {
83	processorMap map[string]thrift.TProcessorFunction
84	handler      Agent
85}
86
87func (p *AgentProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
88	p.processorMap[key] = processor
89}
90
91func (p *AgentProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
92	processor, ok = p.processorMap[key]
93	return processor, ok
94}
95
96func (p *AgentProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
97	return p.processorMap
98}
99
100func NewAgentProcessor(handler Agent) *AgentProcessor {
101
102	self0 := &AgentProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
103	self0.processorMap["emitBatch"] = &agentProcessorEmitBatch{handler: handler}
104	return self0
105}
106
107func (p *AgentProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
108	ctx := context.Background()
109	name, _, seqId, err := iprot.ReadMessageBegin()
110	if err != nil {
111		return false, err
112	}
113	if processor, ok := p.GetProcessorFunction(name); ok {
114		return processor.Process(ctx, seqId, iprot, oprot)
115	}
116	iprot.Skip(thrift.STRUCT)
117	iprot.ReadMessageEnd()
118	x1 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
119	oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
120	x1.Write(oprot)
121	oprot.WriteMessageEnd()
122	oprot.Flush(ctx)
123	return false, x1
124}
125
126type agentProcessorEmitBatch struct {
127	handler Agent
128}
129
130func (p *agentProcessorEmitBatch) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
131	args := AgentEmitBatchArgs{}
132	if err = args.Read(iprot); err != nil {
133		iprot.ReadMessageEnd()
134		return false, err
135	}
136
137	iprot.ReadMessageEnd()
138	var err2 error
139	if err2 = p.handler.EmitBatch(args.Batch); err2 != nil {
140		return true, err2
141	}
142	return true, nil
143}
144
145// HELPER FUNCTIONS AND STRUCTURES
146
147// Attributes:
148//  - Batch
149type AgentEmitBatchArgs struct {
150	Batch *Batch `thrift:"batch,1" json:"batch"`
151}
152
153func NewAgentEmitBatchArgs() *AgentEmitBatchArgs {
154	return &AgentEmitBatchArgs{}
155}
156
157var AgentEmitBatchArgs_Batch_DEFAULT *Batch
158
159func (p *AgentEmitBatchArgs) GetBatch() *Batch {
160	if !p.IsSetBatch() {
161		return AgentEmitBatchArgs_Batch_DEFAULT
162	}
163	return p.Batch
164}
165func (p *AgentEmitBatchArgs) IsSetBatch() bool {
166	return p.Batch != nil
167}
168
169func (p *AgentEmitBatchArgs) Read(iprot thrift.TProtocol) error {
170	if _, err := iprot.ReadStructBegin(); err != nil {
171		return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
172	}
173
174	for {
175		_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
176		if err != nil {
177			return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
178		}
179		if fieldTypeId == thrift.STOP {
180			break
181		}
182		switch fieldId {
183		case 1:
184			if err := p.readField1(iprot); err != nil {
185				return err
186			}
187		default:
188			if err := iprot.Skip(fieldTypeId); err != nil {
189				return err
190			}
191		}
192		if err := iprot.ReadFieldEnd(); err != nil {
193			return err
194		}
195	}
196	if err := iprot.ReadStructEnd(); err != nil {
197		return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
198	}
199	return nil
200}
201
202func (p *AgentEmitBatchArgs) readField1(iprot thrift.TProtocol) error {
203	p.Batch = &Batch{}
204	if err := p.Batch.Read(iprot); err != nil {
205		return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Batch), err)
206	}
207	return nil
208}
209
210func (p *AgentEmitBatchArgs) Write(oprot thrift.TProtocol) error {
211	if err := oprot.WriteStructBegin("emitBatch_args"); err != nil {
212		return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
213	}
214	if err := p.writeField1(oprot); err != nil {
215		return err
216	}
217	if err := oprot.WriteFieldStop(); err != nil {
218		return thrift.PrependError("write field stop error: ", err)
219	}
220	if err := oprot.WriteStructEnd(); err != nil {
221		return thrift.PrependError("write struct stop error: ", err)
222	}
223	return nil
224}
225
226func (p *AgentEmitBatchArgs) writeField1(oprot thrift.TProtocol) (err error) {
227	if err := oprot.WriteFieldBegin("batch", thrift.STRUCT, 1); err != nil {
228		return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:batch: ", p), err)
229	}
230	if err := p.Batch.Write(oprot); err != nil {
231		return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Batch), err)
232	}
233	if err := oprot.WriteFieldEnd(); err != nil {
234		return thrift.PrependError(fmt.Sprintf("%T write field end error 1:batch: ", p), err)
235	}
236	return err
237}
238
239func (p *AgentEmitBatchArgs) String() string {
240	if p == nil {
241		return "<nil>"
242	}
243	return fmt.Sprintf("AgentEmitBatchArgs(%+v)", *p)
244}
245