Codebase list golang-github-go-kit-kit / 48b4028
Updated tracing readme's and removed deprecated tracing/zipkin package Bas van Beek 7 years ago
38 changed file(s) with 204 addition(s) and 17427 deletion(s). Raw diff Collapse all Expand all
00 # package tracing
11
22 `package tracing` provides [Dapper][]-style request tracing to services.
3 An implementation exists for [Zipkin][]; [Appdash][] support is planned.
4
5 [Dapper]: http://research.google.com/pubs/pub36356.html
6 [Zipkin]: https://blog.twitter.com/2012/distributed-systems-tracing-with-zipkin
7 [Appdash]: https://github.com/sourcegraph/appdash
83
94 ## Rationale
105
138 hot spots, and diagnosing errors. All microservice infrastructures will
149 benefit from request tracing; sufficiently large infrastructures will require
1510 it.
11
12 ## OpenTracing
13
14 Go kit builds on top of the [OpenTracing] API and uses the [opentracing-go]
15 package to provide tracing middlewares for its servers and clients. Currently
16 `kit/transport/http` and `kit/transport/grpc` transports are supported.
17
18 Since [OpenTracing] is an upcoming standard API, Go kit should support a
19 multitude of tracing backends. If a Tracer implementation in Go for your
20 back-end exists, it should work out of the box. The following tracing back-ends
21 are known to work with Go kit through the OpenTracing interface and are
22 highlighted in the [addsvc] example.
23
24
25 ### LightStep
26
27 [LightStep] support is available through their standard Go package
28 [lightstep-tracer-go].
29
30 ### AppDash
31
32 [Appdash] support is available straight from their system repository in the
33 [appdash/opentracing] directory.
34
35 ### Zipkin
36
37 [Zipkin] support is now available from the [zipkin-go-opentracing] package which
38 can be found at the [Open Zipkin GitHub] page. This means our old custom
39 `tracing/zipkin` package is now deprecated. In the `kit/tracing/zipkin`
40 directory you can still find the `docker-compose` script to bootstrap a Zipkin
41 development environment and a [README] detailing how to transition from the
42 old package to the new.
43
44 [Dapper]: http://research.google.com/pubs/pub36356.html
45 [addsvc]:https://github.com/go-kit/kit/tree/master/examples/addsvc
46 [README]: https://github.com/go-kit/kit/blob/master/tracing/zipkin/README.md
47
48 [OpenTracing]: http://opentracing.io
49 [opentracing-go]: https://github.com/opentracing/opentracing-go
50
51 [Zipkin]: http://zipkin.io/
52 [Open Zipkin GitHub]: https://github.com/openzipkin
53 [zipkin-go-opentracing]: https://github.com/openzipkin/zipkin-go-opentracing
54
55 [Appdash]: https://github.com/sourcegraph/appdash
56 [appdash/opentracing]: https://github.com/sourcegraph/appdash/tree/master/opentracing
57
58 [LightStep]: http://lightstep.com/
59 [lightstep-tracer-go]: https://github.com/lightstep/lightstep-tracer-go
33
44 Setting up [Zipkin] is not an easy thing to do. It will also demand quite some
55 resources. To help you get started with development and testing we've made a
6 docker-compose file available for running a full Zipkin stack. See the
7 `kit/tracing/zipkin/_docker` subdirectory.
6 docker-compose file available for running a full Zipkin stack.
87
98 You will need [docker-compose] 1.6.0+ and [docker-engine] 1.10.0+.
109
1312 hostname of the VM running the docker containers.
1413
1514 ```sh
16 cd tracing/zipkin/_docker
15 cd tracing/zipkin
1716 HOSTNAME=localhost docker-compose -f docker-compose-zipkin.yml up
1817 ```
1918
3534
3635 ## Middleware Usage
3736
38 Wrap a server- or client-side [endpoint][] so that it emits traces to a Zipkin
39 collector. Make sure the host given to `MakeNewSpanFunc` resolves to an IP. If
40 not your span will silently fail!
37 Follow the [addsvc] example to check out how to wire the Zipkin Middleware. The
38 changes should be relatively minor.
4139
42 [endpoint]: http://godoc.org/github.com/go-kit/kit/endpoint#Endpoint
40 The [zipkin-go-opentracing] package has support for Kafka and Scribe collectors
41 as well as using Go Kit's [Log] package for logging.
4342
44 If needing to create child spans in methods or calling another service from your
45 service method, it is highly recommended to request a context parameter so you
46 can transfer the needed metadata for traces across service boundaries.
43 ### Span per Node vs. Span per RPC
44 OpenTracing tends to support the `span per node` model, meaning the server and
45 client side of an RPC call are dealt with in separate spans. This diverts from
46 the Zipkin V1 model which is more tailored towards the `span per RPC call` model
47 in which the server and client side annotations of the same RPC call are part of
48 the same span. The [zipkin-go-opentracing] implementation allows you to choose
49 which model you wish to use. Make sure you select the same model consistently
50 for all your services that are required to talk to each other or you will have
51 trace propagation issues. If using non OpenTracing / legacy instrumentation use
52 the `span per RPC call` model.
4753
48 It is also wise to always return error parameters with your service method
49 calls, even if your service method implementations will not throw errors
50 themselves. The error return parameter can be wired to pass the potential
51 transport errors when consuming your service API in a networked environment.
54 To adhere to the OpenTracing philosophy the Tracer defaults to `span per node`.
55 To set the `span per RPC call` mode start your tracer like this:
5256
5357 ```go
54 func main() {
58 tracer, err = zipkin.NewTracer(
59 zipkin.NewRecorder(...),
60 zipkin.ClientServerSameSpan(true),
61 )
62 ```
63
64 [zipkin-go-opentracing]: https://github.com/openzipkin/zipkin-go-opentracing
65 [addsvc]:https://github.com/go-kit/kit/tree/master/examples/addsvc
66 [Log]: https://github.com/go-kit/kit/tree/master/log
67
68 ### Tracing Resources
69
70 In our legacy implementation we had the `NewChildSpan` method to allow
71 annotation of resources such as databases, caches and other services that do not
72 have server side tracing support. Since OpenTracing has no specific method of
73 dealing with these items explicitely that is compatible with Zipkin's `SA`
74 annotation the [zipkin-go-opentracing] has implemented support using the
75 OpenTracing Tags system. Here is an example of how one would be able to record
76 a resource span compatible with standard OpenTracing and triggering an `SA`
77 annotation in [zipkin-go-opentracing]:
78
79 ```go
80 // you need to import the ext package for the Tag helper functions
81 import (
82 "github.com/opentracing/opentracing-go"
83 "github.com/opentracing/opentracing-go/ext"
84 )
85
86 func (svc *Service) GetMeSomeExamples(ctx context.Context, ...) ([]Examples, error) {
87 // Example of annotating a database query:
5588 var (
56 // myHost MUST resolve to an IP or your span will not show up in Zipkin.
57 myHost = "instance01.addsvc.internal.net:8000"
58 myService = "AddService"
59 myMethod = "Add"
60 url = myHost + "/add/"
61 kafkaHost = []string{"kafka.internal.net:9092"}
89 serviceName = "MySQL"
90 serviceHost = "mysql.example.com"
91 servicePort = uint16(3306)
92 queryLabel = "GetExamplesByParam"
93 query = "select * from example where param = 'value'"
6294 )
6395
64 ctx := context.Background()
96 // retrieve the parent span, if not found create a new trace
97 parentSpan := opentracing.SpanFromContext(ctx)
98 if parentSpan == nil {
99 parentSpan = opentracing.StartSpan(queryLabel)
100 }
65101
66 // Set Up Zipkin Collector and Span factory
67 spanFunc := zipkin.MakeNewSpanFunc(myHost, myService, myMethod)
68 collector, _ := zipkin.NewKafkaCollector(kafkaHost)
102 // create a new span to record the resource interaction
103 span := opentracing.StartChildSpan(parentSpan, queryLabel)
69104
70 // Server-side Wiring
71 var server endpoint.Endpoint
72 server = makeEndpoint() // for your service
73 // wrap endpoint with Zipkin tracing middleware
74 server = zipkin.AnnotateServer(spanFunc, collector)(server)
105 // span.kind "resource" triggers SA annotation
106 ext.SpanKind.Set(span, "resource")
75107
76 http.Handle(
77 "/add/",
78 httptransport.NewServer(
79 ctx,
80 server,
81 decodeRequestFunc,
82 encodeResponseFunc,
83 httptransport.ServerBefore(
84 zipkin.ToContext(spanFunc),
85 ),
86 ),
87 )
88 ...
108 // this will label the span's service & hostPort (called Endpoint in Zipkin)
109 ext.PeerService.Set(span, serviceName)
110 ext.PeerHostname,Set(span, serviceHost)
111 ext.PeerPort.Set(span, servicePort)
89112
90 // Client-side
91 var client endpoint.Endpoint
92 client = httptransport.NewClient(
93 "GET",
94 URL,
95 encodeRequestFunc,
96 decodeResponseFunc,
97 httptransport.ClientBefore(zipkin.ToRequest(spanFunc)),
98 ).Endpoint()
99 client = zipkin.AnnotateClient(spanFunc, collector)(client)
113 // a Tag is the equivalent of a Zipkin Binary Annotation (key:value pair)
114 span.SetTag("query", query)
100115
101 ctx, cancel := context.WithTimeout(ctx, myTimeout)
102 defer cancel()
116 // a LogEvent is the equivalent of a Zipkin Annotation (timestamped)
117 span.LogEvent("query:start")
103118
104 reply, err := client(ctx, param1, param2)
105 // do something with the response/error
119 // do the actual query...
120
121 // let's annotate the end...
122 span.LogEvent("query:end")
123
124 // we're done with the span. send it to the SpanRecorder for collection...
125 span.Finish()
126
127 // do other stuff
106128 ...
107129 }
108130 ```
109
110 ## Annotating Remote Resources
111
112 Next to the above shown examples of wiring server-side and client-side tracing
113 middlewares, you can also span resources called from your service methods.
114
115 To do this, the service method needs to include a context parameter. From your
116 endpoint wrapper you can inject the endpoint context which will hold the parent
117 span already created by the server-side middleware. If the resource is a remote
118 database you can use the `zipkin.ServerAddr` spanOption to identify the remote
119 host:port and the display name of this resource.
120
121 ```go
122 type MyService struct {
123 // add a Zipkin Collector to your service implementation's properties.
124 Collector zipkin.Collector
125 }
126
127 // Example of the endpoint.Endpoint to service method wrapper, injecting the
128 // context provided by the transport server.
129 func makeComplexEndpoint() endpoint.Endpoint {
130 return func(ctx context.Context, request interface{}) (interface{}, error) {
131 req := request.(ComplexRequest)
132 v, err := svc.Complex(ctx, req.A, req.B)
133 return ComplexResponse{V: v, Err: err}, nil
134 }
135 }
136
137 // Complex is an example method of our service, displaying the tracing of a
138 // remote database resource.
139 func (s *MyService) Complex(ctx context.Context, A someType, B otherType) (returnType, error) {
140 // we've parsed the incoming parameters and now we need to query the database.
141 // we wish to include this action into our trace.
142 span, collect := zipkin.NewChildSpan(
143 ctx,
144 s.Collector,
145 "complexQuery",
146 zipkin.ServerAddr(
147 "mysql01.internal.net:3306",
148 "MySQL",
149 ),
150 )
151 // you probably want to binary annotate your query
152 span.AnnotateBinary("query", "SELECT ... FROM ... WHERE ... ORDER BY ..."),
153 // annotate the start of the query
154 span.Annotate("complexQuery:start")
155 // do the query and handle resultset
156 ...
157 // annotate we are done with the query
158 span.Annotate("complexQuery:end")
159 // maybe binary annotate some items returned by the resultset
160 ...
161 // when done with all annotations, collect the span
162 collect()
163 ...
164 }
165 ```
+0
-76
tracing/zipkin/_docker/docker-compose-zipkin.yml less more
0 # This file uses the version 2 docker-compose file format, described here:
1 # https://docs.docker.com/compose/compose-file/#version-2
2 #
3 # It runs the zipkin-cassandra, zipkin-collector, zipkin-query, zipkin-web, and
4 # zookeeper-exhibitor containers.
5 #
6 # On linux you probably want to start this composition like this:
7 #
8 # HOSTNAME=localhost docker-compose -f docker-compose-zipkin.yml up
9 #
10 # On OS X you will probably start like this:
11 #
12 # HOSTNAME=default docker-compose -f docker-compose-zipkin.yml up
13
14 version: '2'
15 services:
16 cassandra:
17 image: openzipkin/zipkin-cassandra:1.39.4
18 network_mode: host
19
20 zookeeper:
21 image: mbabineau/zookeeper-exhibitor:latest
22 network_mode: host
23 environment:
24 HOSTNAME: ${HOSTNAME}
25
26 kafka:
27 image: wurstmeister/kafka
28 network_mode: host
29 environment:
30 KAFKA_CREATE_TOPICS: "zipkin:1:1"
31 KAFKA_ZOOKEEPER_CONNECTION_TIMEOUT_MS: 60000
32 KAFKA_ADVERTISED_PORT: 9092
33 KAFKA_ADVERTISED_HOST_NAME: ${HOSTNAME}
34 KAFKA_ZOOKEEPER_CONNECT: ${HOSTNAME}:2181
35 depends_on:
36 - zookeeper
37
38 collector:
39 image: openzipkin/zipkin-collector:1.39.4
40 network_mode: host
41 environment:
42 STORAGE_TYPE: cassandra
43 TRANSPORT_TYPE: kafka
44 CASSANDRA_CONTACT_POINTS: ${HOSTNAME}
45 KAFKA_ZOOKEEPER: ${HOSTNAME}:2181
46 METADATA_BROKER_LIST: ${HOSTNAME}:9092
47 depends_on:
48 - cassandra
49 - kafka
50
51 query:
52 image: openzipkin/zipkin-query:1.39.4
53 network_mode: host
54 environment:
55 STORAGE_TYPE: cassandra
56 TRANSPORT_TYPE: kafka
57 CASSANDRA_CONTACT_POINTS: ${HOSTNAME}
58 KAFKA_ZOOKEEPER: ${HOSTNAME}:2181
59 METADATA_BROKER_LIST: ${HOSTNAME}:9092
60 depends_on:
61 - cassandra
62 - kafka
63
64 web:
65 image: openzipkin/zipkin-web:1.39.4
66 network_mode: host
67 environment:
68 TRANSPORT_TYPE: kafka
69 KAFKA_ZOOKEEPER: ${HOSTNAME}:2181
70 METADATA_BROKER_LIST: ${HOSTNAME}:9092
71 QUERY_PORT_9411_TCP_ADDR: ${HOSTNAME}
72 ROOTURL: http://${HOSTNAME}:8080
73 depends_on:
74 - cassandra
75 - kafka
+0
-11
tracing/zipkin/_thrift/compile.sh less more
0 #!/usr/bin/env sh
1
2 # Thrift code generation for Go is broken in the current stable (0.9.2)
3 # release. Leaving this stubbed out until the fix is released.
4 # https://issues.apache.org/jira/browse/THRIFT-3021
5
6 # https://thrift.apache.org/tutorial/go
7 for f in *.thrift ; do
8 thrift -r --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift $f
9 done
10
+0
-18
tracing/zipkin/_thrift/gen-go/scribe/constants.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package scribe
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf
14 var _ = bytes.Equal
15
16 func init() {
17 }
+0
-150
tracing/zipkin/_thrift/gen-go/scribe/scribe-remote/scribe-remote.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package main
4
5 import (
6 "flag"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 "math"
10 "net"
11 "net/url"
12 "os"
13 "scribe"
14 "strconv"
15 "strings"
16 )
17
18 func Usage() {
19 fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
20 flag.PrintDefaults()
21 fmt.Fprintln(os.Stderr, "\nFunctions:")
22 fmt.Fprintln(os.Stderr, " ResultCode Log( messages)")
23 fmt.Fprintln(os.Stderr)
24 os.Exit(0)
25 }
26
27 func main() {
28 flag.Usage = Usage
29 var host string
30 var port int
31 var protocol string
32 var urlString string
33 var framed bool
34 var useHttp bool
35 var parsedUrl url.URL
36 var trans thrift.TTransport
37 _ = strconv.Atoi
38 _ = math.Abs
39 flag.Usage = Usage
40 flag.StringVar(&host, "h", "localhost", "Specify host and port")
41 flag.IntVar(&port, "p", 9090, "Specify port")
42 flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
43 flag.StringVar(&urlString, "u", "", "Specify the url")
44 flag.BoolVar(&framed, "framed", false, "Use framed transport")
45 flag.BoolVar(&useHttp, "http", false, "Use http")
46 flag.Parse()
47
48 if len(urlString) > 0 {
49 parsedUrl, err := url.Parse(urlString)
50 if err != nil {
51 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
52 flag.Usage()
53 }
54 host = parsedUrl.Host
55 useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
56 } else if useHttp {
57 _, err := url.Parse(fmt.Sprint("http://", host, ":", port))
58 if err != nil {
59 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
60 flag.Usage()
61 }
62 }
63
64 cmd := flag.Arg(0)
65 var err error
66 if useHttp {
67 trans, err = thrift.NewTHttpClient(parsedUrl.String())
68 } else {
69 portStr := fmt.Sprint(port)
70 if strings.Contains(host, ":") {
71 host, portStr, err = net.SplitHostPort(host)
72 if err != nil {
73 fmt.Fprintln(os.Stderr, "error with host:", err)
74 os.Exit(1)
75 }
76 }
77 trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
78 if err != nil {
79 fmt.Fprintln(os.Stderr, "error resolving address:", err)
80 os.Exit(1)
81 }
82 if framed {
83 trans = thrift.NewTFramedTransport(trans)
84 }
85 }
86 if err != nil {
87 fmt.Fprintln(os.Stderr, "Error creating transport", err)
88 os.Exit(1)
89 }
90 defer trans.Close()
91 var protocolFactory thrift.TProtocolFactory
92 switch protocol {
93 case "compact":
94 protocolFactory = thrift.NewTCompactProtocolFactory()
95 break
96 case "simplejson":
97 protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
98 break
99 case "json":
100 protocolFactory = thrift.NewTJSONProtocolFactory()
101 break
102 case "binary", "":
103 protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
104 break
105 default:
106 fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
107 Usage()
108 os.Exit(1)
109 }
110 client := scribe.NewScribeClientFactory(trans, protocolFactory)
111 if err := trans.Open(); err != nil {
112 fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
113 os.Exit(1)
114 }
115
116 switch cmd {
117 case "Log":
118 if flag.NArg()-1 != 1 {
119 fmt.Fprintln(os.Stderr, "Log requires 1 args")
120 flag.Usage()
121 }
122 arg5 := flag.Arg(1)
123 mbTrans6 := thrift.NewTMemoryBufferLen(len(arg5))
124 defer mbTrans6.Close()
125 _, err7 := mbTrans6.WriteString(arg5)
126 if err7 != nil {
127 Usage()
128 return
129 }
130 factory8 := thrift.NewTSimpleJSONProtocolFactory()
131 jsProt9 := factory8.GetProtocol(mbTrans6)
132 containerStruct0 := scribe.NewLogArgs()
133 err10 := containerStruct0.ReadField1(jsProt9)
134 if err10 != nil {
135 Usage()
136 return
137 }
138 argvalue0 := containerStruct0.Messages
139 value0 := argvalue0
140 fmt.Print(client.Log(value0))
141 fmt.Print("\n")
142 break
143 case "":
144 Usage()
145 break
146 default:
147 fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
148 }
149 }
+0
-418
tracing/zipkin/_thrift/gen-go/scribe/scribe.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package scribe
4
5 import (
6 "bytes"
7 "fmt"
8
9 "github.com/apache/thrift/lib/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 Scribe interface {
18 // Parameters:
19 // - Messages
20 Log(messages []*LogEntry) (r ResultCode, err error)
21 }
22
23 type ScribeClient struct {
24 Transport thrift.TTransport
25 ProtocolFactory thrift.TProtocolFactory
26 InputProtocol thrift.TProtocol
27 OutputProtocol thrift.TProtocol
28 SeqId int32
29 }
30
31 func NewScribeClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ScribeClient {
32 return &ScribeClient{Transport: t,
33 ProtocolFactory: f,
34 InputProtocol: f.GetProtocol(t),
35 OutputProtocol: f.GetProtocol(t),
36 SeqId: 0,
37 }
38 }
39
40 func NewScribeClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ScribeClient {
41 return &ScribeClient{Transport: t,
42 ProtocolFactory: nil,
43 InputProtocol: iprot,
44 OutputProtocol: oprot,
45 SeqId: 0,
46 }
47 }
48
49 // Parameters:
50 // - Messages
51 func (p *ScribeClient) Log(messages []*LogEntry) (r ResultCode, err error) {
52 if err = p.sendLog(messages); err != nil {
53 return
54 }
55 return p.recvLog()
56 }
57
58 func (p *ScribeClient) sendLog(messages []*LogEntry) (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("Log", thrift.CALL, p.SeqId); err != nil {
66 return
67 }
68 args := LogArgs{
69 Messages: messages,
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 *ScribeClient) recvLog() (value ResultCode, err error) {
81 iprot := p.InputProtocol
82 if iprot == nil {
83 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
84 p.InputProtocol = iprot
85 }
86 _, mTypeId, seqId, err := iprot.ReadMessageBegin()
87 if err != nil {
88 return
89 }
90 if mTypeId == thrift.EXCEPTION {
91 error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
92 var error1 error
93 error1, err = error0.Read(iprot)
94 if err != nil {
95 return
96 }
97 if err = iprot.ReadMessageEnd(); err != nil {
98 return
99 }
100 err = error1
101 return
102 }
103 if p.SeqId != seqId {
104 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Log failed: out of sequence response")
105 return
106 }
107 result := LogResult{}
108 if err = result.Read(iprot); err != nil {
109 return
110 }
111 if err = iprot.ReadMessageEnd(); err != nil {
112 return
113 }
114 value = result.GetSuccess()
115 return
116 }
117
118 type ScribeProcessor struct {
119 processorMap map[string]thrift.TProcessorFunction
120 handler Scribe
121 }
122
123 func (p *ScribeProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
124 p.processorMap[key] = processor
125 }
126
127 func (p *ScribeProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
128 processor, ok = p.processorMap[key]
129 return processor, ok
130 }
131
132 func (p *ScribeProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
133 return p.processorMap
134 }
135
136 func NewScribeProcessor(handler Scribe) *ScribeProcessor {
137
138 self2 := &ScribeProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
139 self2.processorMap["Log"] = &scribeProcessorLog{handler: handler}
140 return self2
141 }
142
143 func (p *ScribeProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
144 name, _, seqId, err := iprot.ReadMessageBegin()
145 if err != nil {
146 return false, err
147 }
148 if processor, ok := p.GetProcessorFunction(name); ok {
149 return processor.Process(seqId, iprot, oprot)
150 }
151 iprot.Skip(thrift.STRUCT)
152 iprot.ReadMessageEnd()
153 x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
154 oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
155 x3.Write(oprot)
156 oprot.WriteMessageEnd()
157 oprot.Flush()
158 return false, x3
159
160 }
161
162 type scribeProcessorLog struct {
163 handler Scribe
164 }
165
166 func (p *scribeProcessorLog) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
167 args := LogArgs{}
168 if err = args.Read(iprot); err != nil {
169 iprot.ReadMessageEnd()
170 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
171 oprot.WriteMessageBegin("Log", thrift.EXCEPTION, seqId)
172 x.Write(oprot)
173 oprot.WriteMessageEnd()
174 oprot.Flush()
175 return false, err
176 }
177
178 iprot.ReadMessageEnd()
179 result := LogResult{}
180 var retval ResultCode
181 var err2 error
182 if retval, err2 = p.handler.Log(args.Messages); err2 != nil {
183 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Log: "+err2.Error())
184 oprot.WriteMessageBegin("Log", thrift.EXCEPTION, seqId)
185 x.Write(oprot)
186 oprot.WriteMessageEnd()
187 oprot.Flush()
188 return true, err2
189 } else {
190 result.Success = &retval
191 }
192 if err2 = oprot.WriteMessageBegin("Log", thrift.REPLY, seqId); err2 != nil {
193 err = err2
194 }
195 if err2 = result.Write(oprot); err == nil && err2 != nil {
196 err = err2
197 }
198 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
199 err = err2
200 }
201 if err2 = oprot.Flush(); err == nil && err2 != nil {
202 err = err2
203 }
204 if err != nil {
205 return
206 }
207 return true, err
208 }
209
210 // HELPER FUNCTIONS AND STRUCTURES
211
212 type LogArgs struct {
213 Messages []*LogEntry `thrift:"messages,1" json:"messages"`
214 }
215
216 func NewLogArgs() *LogArgs {
217 return &LogArgs{}
218 }
219
220 func (p *LogArgs) GetMessages() []*LogEntry {
221 return p.Messages
222 }
223 func (p *LogArgs) Read(iprot thrift.TProtocol) error {
224 if _, err := iprot.ReadStructBegin(); err != nil {
225 return fmt.Errorf("%T read error: %s", p, err)
226 }
227 for {
228 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
229 if err != nil {
230 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
231 }
232 if fieldTypeId == thrift.STOP {
233 break
234 }
235 switch fieldId {
236 case 1:
237 if err := p.ReadField1(iprot); err != nil {
238 return err
239 }
240 default:
241 if err := iprot.Skip(fieldTypeId); err != nil {
242 return err
243 }
244 }
245 if err := iprot.ReadFieldEnd(); err != nil {
246 return err
247 }
248 }
249 if err := iprot.ReadStructEnd(); err != nil {
250 return fmt.Errorf("%T read struct end error: %s", p, err)
251 }
252 return nil
253 }
254
255 func (p *LogArgs) ReadField1(iprot thrift.TProtocol) error {
256 _, size, err := iprot.ReadListBegin()
257 if err != nil {
258 return fmt.Errorf("error reading list begin: %s", err)
259 }
260 tSlice := make([]*LogEntry, 0, size)
261 p.Messages = tSlice
262 for i := 0; i < size; i++ {
263 _elem4 := &LogEntry{}
264 if err := _elem4.Read(iprot); err != nil {
265 return fmt.Errorf("%T error reading struct: %s", _elem4, err)
266 }
267 p.Messages = append(p.Messages, _elem4)
268 }
269 if err := iprot.ReadListEnd(); err != nil {
270 return fmt.Errorf("error reading list end: %s", err)
271 }
272 return nil
273 }
274
275 func (p *LogArgs) Write(oprot thrift.TProtocol) error {
276 if err := oprot.WriteStructBegin("Log_args"); err != nil {
277 return fmt.Errorf("%T write struct begin error: %s", p, err)
278 }
279 if err := p.writeField1(oprot); err != nil {
280 return err
281 }
282 if err := oprot.WriteFieldStop(); err != nil {
283 return fmt.Errorf("write field stop error: %s", err)
284 }
285 if err := oprot.WriteStructEnd(); err != nil {
286 return fmt.Errorf("write struct stop error: %s", err)
287 }
288 return nil
289 }
290
291 func (p *LogArgs) writeField1(oprot thrift.TProtocol) (err error) {
292 if err := oprot.WriteFieldBegin("messages", thrift.LIST, 1); err != nil {
293 return fmt.Errorf("%T write field begin error 1:messages: %s", p, err)
294 }
295 if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Messages)); err != nil {
296 return fmt.Errorf("error writing list begin: %s", err)
297 }
298 for _, v := range p.Messages {
299 if err := v.Write(oprot); err != nil {
300 return fmt.Errorf("%T error writing struct: %s", v, err)
301 }
302 }
303 if err := oprot.WriteListEnd(); err != nil {
304 return fmt.Errorf("error writing list end: %s", err)
305 }
306 if err := oprot.WriteFieldEnd(); err != nil {
307 return fmt.Errorf("%T write field end error 1:messages: %s", p, err)
308 }
309 return err
310 }
311
312 func (p *LogArgs) String() string {
313 if p == nil {
314 return "<nil>"
315 }
316 return fmt.Sprintf("LogArgs(%+v)", *p)
317 }
318
319 type LogResult struct {
320 Success *ResultCode `thrift:"success,0" json:"success"`
321 }
322
323 func NewLogResult() *LogResult {
324 return &LogResult{}
325 }
326
327 var LogResult_Success_DEFAULT ResultCode
328
329 func (p *LogResult) GetSuccess() ResultCode {
330 if !p.IsSetSuccess() {
331 return LogResult_Success_DEFAULT
332 }
333 return *p.Success
334 }
335 func (p *LogResult) IsSetSuccess() bool {
336 return p.Success != nil
337 }
338
339 func (p *LogResult) Read(iprot thrift.TProtocol) error {
340 if _, err := iprot.ReadStructBegin(); err != nil {
341 return fmt.Errorf("%T read error: %s", p, err)
342 }
343 for {
344 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
345 if err != nil {
346 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
347 }
348 if fieldTypeId == thrift.STOP {
349 break
350 }
351 switch fieldId {
352 case 0:
353 if err := p.ReadField0(iprot); err != nil {
354 return err
355 }
356 default:
357 if err := iprot.Skip(fieldTypeId); err != nil {
358 return err
359 }
360 }
361 if err := iprot.ReadFieldEnd(); err != nil {
362 return err
363 }
364 }
365 if err := iprot.ReadStructEnd(); err != nil {
366 return fmt.Errorf("%T read struct end error: %s", p, err)
367 }
368 return nil
369 }
370
371 func (p *LogResult) ReadField0(iprot thrift.TProtocol) error {
372 if v, err := iprot.ReadI32(); err != nil {
373 return fmt.Errorf("error reading field 0: %s", err)
374 } else {
375 temp := ResultCode(v)
376 p.Success = &temp
377 }
378 return nil
379 }
380
381 func (p *LogResult) Write(oprot thrift.TProtocol) error {
382 if err := oprot.WriteStructBegin("Log_result"); err != nil {
383 return fmt.Errorf("%T write struct begin error: %s", p, err)
384 }
385 if err := p.writeField0(oprot); err != nil {
386 return err
387 }
388 if err := oprot.WriteFieldStop(); err != nil {
389 return fmt.Errorf("write field stop error: %s", err)
390 }
391 if err := oprot.WriteStructEnd(); err != nil {
392 return fmt.Errorf("write struct stop error: %s", err)
393 }
394 return nil
395 }
396
397 func (p *LogResult) writeField0(oprot thrift.TProtocol) (err error) {
398 if p.IsSetSuccess() {
399 if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil {
400 return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
401 }
402 if err := oprot.WriteI32(int32(*p.Success)); err != nil {
403 return fmt.Errorf("%T.success (0) field write error: %s", p, err)
404 }
405 if err := oprot.WriteFieldEnd(); err != nil {
406 return fmt.Errorf("%T write field end error 0:success: %s", p, err)
407 }
408 }
409 return err
410 }
411
412 func (p *LogResult) String() string {
413 if p == nil {
414 return "<nil>"
415 }
416 return fmt.Sprintf("LogResult(%+v)", *p)
417 }
+0
-168
tracing/zipkin/_thrift/gen-go/scribe/ttypes.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package scribe
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf
14 var _ = bytes.Equal
15
16 var GoUnusedProtection__ int
17
18 type ResultCode int64
19
20 const (
21 ResultCode_OK ResultCode = 0
22 ResultCode_TRY_LATER ResultCode = 1
23 )
24
25 func (p ResultCode) String() string {
26 switch p {
27 case ResultCode_OK:
28 return "ResultCode_OK"
29 case ResultCode_TRY_LATER:
30 return "ResultCode_TRY_LATER"
31 }
32 return "<UNSET>"
33 }
34
35 func ResultCodeFromString(s string) (ResultCode, error) {
36 switch s {
37 case "ResultCode_OK":
38 return ResultCode_OK, nil
39 case "ResultCode_TRY_LATER":
40 return ResultCode_TRY_LATER, nil
41 }
42 return ResultCode(0), fmt.Errorf("not a valid ResultCode string")
43 }
44
45 func ResultCodePtr(v ResultCode) *ResultCode { return &v }
46
47 type LogEntry struct {
48 Category string `thrift:"category,1" json:"category"`
49 Message string `thrift:"message,2" json:"message"`
50 }
51
52 func NewLogEntry() *LogEntry {
53 return &LogEntry{}
54 }
55
56 func (p *LogEntry) GetCategory() string {
57 return p.Category
58 }
59
60 func (p *LogEntry) GetMessage() string {
61 return p.Message
62 }
63 func (p *LogEntry) Read(iprot thrift.TProtocol) error {
64 if _, err := iprot.ReadStructBegin(); err != nil {
65 return fmt.Errorf("%T read error: %s", p, err)
66 }
67 for {
68 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
69 if err != nil {
70 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
71 }
72 if fieldTypeId == thrift.STOP {
73 break
74 }
75 switch fieldId {
76 case 1:
77 if err := p.ReadField1(iprot); err != nil {
78 return err
79 }
80 case 2:
81 if err := p.ReadField2(iprot); err != nil {
82 return err
83 }
84 default:
85 if err := iprot.Skip(fieldTypeId); err != nil {
86 return err
87 }
88 }
89 if err := iprot.ReadFieldEnd(); err != nil {
90 return err
91 }
92 }
93 if err := iprot.ReadStructEnd(); err != nil {
94 return fmt.Errorf("%T read struct end error: %s", p, err)
95 }
96 return nil
97 }
98
99 func (p *LogEntry) ReadField1(iprot thrift.TProtocol) error {
100 if v, err := iprot.ReadString(); err != nil {
101 return fmt.Errorf("error reading field 1: %s", err)
102 } else {
103 p.Category = v
104 }
105 return nil
106 }
107
108 func (p *LogEntry) ReadField2(iprot thrift.TProtocol) error {
109 if v, err := iprot.ReadString(); err != nil {
110 return fmt.Errorf("error reading field 2: %s", err)
111 } else {
112 p.Message = v
113 }
114 return nil
115 }
116
117 func (p *LogEntry) Write(oprot thrift.TProtocol) error {
118 if err := oprot.WriteStructBegin("LogEntry"); err != nil {
119 return fmt.Errorf("%T write struct begin error: %s", p, err)
120 }
121 if err := p.writeField1(oprot); err != nil {
122 return err
123 }
124 if err := p.writeField2(oprot); err != nil {
125 return err
126 }
127 if err := oprot.WriteFieldStop(); err != nil {
128 return fmt.Errorf("write field stop error: %s", err)
129 }
130 if err := oprot.WriteStructEnd(); err != nil {
131 return fmt.Errorf("write struct stop error: %s", err)
132 }
133 return nil
134 }
135
136 func (p *LogEntry) writeField1(oprot thrift.TProtocol) (err error) {
137 if err := oprot.WriteFieldBegin("category", thrift.STRING, 1); err != nil {
138 return fmt.Errorf("%T write field begin error 1:category: %s", p, err)
139 }
140 if err := oprot.WriteString(string(p.Category)); err != nil {
141 return fmt.Errorf("%T.category (1) field write error: %s", p, err)
142 }
143 if err := oprot.WriteFieldEnd(); err != nil {
144 return fmt.Errorf("%T write field end error 1:category: %s", p, err)
145 }
146 return err
147 }
148
149 func (p *LogEntry) writeField2(oprot thrift.TProtocol) (err error) {
150 if err := oprot.WriteFieldBegin("message", thrift.STRING, 2); err != nil {
151 return fmt.Errorf("%T write field begin error 2:message: %s", p, err)
152 }
153 if err := oprot.WriteString(string(p.Message)); err != nil {
154 return fmt.Errorf("%T.message (2) field write error: %s", p, err)
155 }
156 if err := oprot.WriteFieldEnd(); err != nil {
157 return fmt.Errorf("%T write field end error 2:message: %s", p, err)
158 }
159 return err
160 }
161
162 func (p *LogEntry) String() string {
163 if p == nil {
164 return "<nil>"
165 }
166 return fmt.Sprintf("LogEntry(%+v)", *p)
167 }
+0
-23
tracing/zipkin/_thrift/gen-go/zipkincollector/constants.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package zipkincollector
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 "scribe"
10 "zipkindependencies"
11 )
12
13 // (needed to ensure safety because of naive import list construction.)
14 var _ = thrift.ZERO
15 var _ = fmt.Printf
16 var _ = bytes.Equal
17
18 var _ = scribe.GoUnusedProtection__
19 var _ = zipkindependencies.GoUnusedProtection__
20
21 func init() {
22 }
+0
-205
tracing/zipkin/_thrift/gen-go/zipkincollector/ttypes.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package zipkincollector
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 "scribe"
10 "zipkindependencies"
11 )
12
13 // (needed to ensure safety because of naive import list construction.)
14 var _ = thrift.ZERO
15 var _ = fmt.Printf
16 var _ = bytes.Equal
17
18 var _ = scribe.GoUnusedProtection__
19 var _ = zipkindependencies.GoUnusedProtection__
20 var GoUnusedProtection__ int
21
22 type AdjustableRateException struct {
23 Msg string `thrift:"msg,1" json:"msg"`
24 }
25
26 func NewAdjustableRateException() *AdjustableRateException {
27 return &AdjustableRateException{}
28 }
29
30 func (p *AdjustableRateException) GetMsg() string {
31 return p.Msg
32 }
33 func (p *AdjustableRateException) Read(iprot thrift.TProtocol) error {
34 if _, err := iprot.ReadStructBegin(); err != nil {
35 return fmt.Errorf("%T read error: %s", p, err)
36 }
37 for {
38 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
39 if err != nil {
40 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
41 }
42 if fieldTypeId == thrift.STOP {
43 break
44 }
45 switch fieldId {
46 case 1:
47 if err := p.ReadField1(iprot); err != nil {
48 return err
49 }
50 default:
51 if err := iprot.Skip(fieldTypeId); err != nil {
52 return err
53 }
54 }
55 if err := iprot.ReadFieldEnd(); err != nil {
56 return err
57 }
58 }
59 if err := iprot.ReadStructEnd(); err != nil {
60 return fmt.Errorf("%T read struct end error: %s", p, err)
61 }
62 return nil
63 }
64
65 func (p *AdjustableRateException) ReadField1(iprot thrift.TProtocol) error {
66 if v, err := iprot.ReadString(); err != nil {
67 return fmt.Errorf("error reading field 1: %s", err)
68 } else {
69 p.Msg = v
70 }
71 return nil
72 }
73
74 func (p *AdjustableRateException) Write(oprot thrift.TProtocol) error {
75 if err := oprot.WriteStructBegin("AdjustableRateException"); err != nil {
76 return fmt.Errorf("%T write struct begin error: %s", p, err)
77 }
78 if err := p.writeField1(oprot); err != nil {
79 return err
80 }
81 if err := oprot.WriteFieldStop(); err != nil {
82 return fmt.Errorf("write field stop error: %s", err)
83 }
84 if err := oprot.WriteStructEnd(); err != nil {
85 return fmt.Errorf("write struct stop error: %s", err)
86 }
87 return nil
88 }
89
90 func (p *AdjustableRateException) writeField1(oprot thrift.TProtocol) (err error) {
91 if err := oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil {
92 return fmt.Errorf("%T write field begin error 1:msg: %s", p, err)
93 }
94 if err := oprot.WriteString(string(p.Msg)); err != nil {
95 return fmt.Errorf("%T.msg (1) field write error: %s", p, err)
96 }
97 if err := oprot.WriteFieldEnd(); err != nil {
98 return fmt.Errorf("%T write field end error 1:msg: %s", p, err)
99 }
100 return err
101 }
102
103 func (p *AdjustableRateException) String() string {
104 if p == nil {
105 return "<nil>"
106 }
107 return fmt.Sprintf("AdjustableRateException(%+v)", *p)
108 }
109
110 func (p *AdjustableRateException) Error() string {
111 return p.String()
112 }
113
114 type StoreAggregatesException struct {
115 Msg string `thrift:"msg,1" json:"msg"`
116 }
117
118 func NewStoreAggregatesException() *StoreAggregatesException {
119 return &StoreAggregatesException{}
120 }
121
122 func (p *StoreAggregatesException) GetMsg() string {
123 return p.Msg
124 }
125 func (p *StoreAggregatesException) Read(iprot thrift.TProtocol) error {
126 if _, err := iprot.ReadStructBegin(); err != nil {
127 return fmt.Errorf("%T read error: %s", p, err)
128 }
129 for {
130 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
131 if err != nil {
132 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
133 }
134 if fieldTypeId == thrift.STOP {
135 break
136 }
137 switch fieldId {
138 case 1:
139 if err := p.ReadField1(iprot); err != nil {
140 return err
141 }
142 default:
143 if err := iprot.Skip(fieldTypeId); err != nil {
144 return err
145 }
146 }
147 if err := iprot.ReadFieldEnd(); err != nil {
148 return err
149 }
150 }
151 if err := iprot.ReadStructEnd(); err != nil {
152 return fmt.Errorf("%T read struct end error: %s", p, err)
153 }
154 return nil
155 }
156
157 func (p *StoreAggregatesException) ReadField1(iprot thrift.TProtocol) error {
158 if v, err := iprot.ReadString(); err != nil {
159 return fmt.Errorf("error reading field 1: %s", err)
160 } else {
161 p.Msg = v
162 }
163 return nil
164 }
165
166 func (p *StoreAggregatesException) Write(oprot thrift.TProtocol) error {
167 if err := oprot.WriteStructBegin("StoreAggregatesException"); err != nil {
168 return fmt.Errorf("%T write struct begin error: %s", p, err)
169 }
170 if err := p.writeField1(oprot); err != nil {
171 return err
172 }
173 if err := oprot.WriteFieldStop(); err != nil {
174 return fmt.Errorf("write field stop error: %s", err)
175 }
176 if err := oprot.WriteStructEnd(); err != nil {
177 return fmt.Errorf("write struct stop error: %s", err)
178 }
179 return nil
180 }
181
182 func (p *StoreAggregatesException) writeField1(oprot thrift.TProtocol) (err error) {
183 if err := oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil {
184 return fmt.Errorf("%T write field begin error 1:msg: %s", p, err)
185 }
186 if err := oprot.WriteString(string(p.Msg)); err != nil {
187 return fmt.Errorf("%T.msg (1) field write error: %s", p, err)
188 }
189 if err := oprot.WriteFieldEnd(); err != nil {
190 return fmt.Errorf("%T write field end error 1:msg: %s", p, err)
191 }
192 return err
193 }
194
195 func (p *StoreAggregatesException) String() string {
196 if p == nil {
197 return "<nil>"
198 }
199 return fmt.Sprintf("StoreAggregatesException(%+v)", *p)
200 }
201
202 func (p *StoreAggregatesException) Error() string {
203 return p.String()
204 }
+0
-234
tracing/zipkin/_thrift/gen-go/zipkincollector/zipkin_collector-remote/zipkin_collector-remote.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package main
4
5 import (
6 "flag"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 "math"
10 "net"
11 "net/url"
12 "os"
13 "strconv"
14 "strings"
15 "zipkincollector"
16 )
17
18 func Usage() {
19 fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
20 flag.PrintDefaults()
21 fmt.Fprintln(os.Stderr, "\nFunctions:")
22 fmt.Fprintln(os.Stderr, " void storeTopAnnotations(string service_name, annotations)")
23 fmt.Fprintln(os.Stderr, " void storeTopKeyValueAnnotations(string service_name, annotations)")
24 fmt.Fprintln(os.Stderr, " void storeDependencies(Dependencies dependencies)")
25 fmt.Fprintln(os.Stderr, " ResultCode Log( messages)")
26 fmt.Fprintln(os.Stderr)
27 os.Exit(0)
28 }
29
30 func main() {
31 flag.Usage = Usage
32 var host string
33 var port int
34 var protocol string
35 var urlString string
36 var framed bool
37 var useHttp bool
38 var parsedUrl url.URL
39 var trans thrift.TTransport
40 _ = strconv.Atoi
41 _ = math.Abs
42 flag.Usage = Usage
43 flag.StringVar(&host, "h", "localhost", "Specify host and port")
44 flag.IntVar(&port, "p", 9090, "Specify port")
45 flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
46 flag.StringVar(&urlString, "u", "", "Specify the url")
47 flag.BoolVar(&framed, "framed", false, "Use framed transport")
48 flag.BoolVar(&useHttp, "http", false, "Use http")
49 flag.Parse()
50
51 if len(urlString) > 0 {
52 parsedUrl, err := url.Parse(urlString)
53 if err != nil {
54 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
55 flag.Usage()
56 }
57 host = parsedUrl.Host
58 useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
59 } else if useHttp {
60 _, err := url.Parse(fmt.Sprint("http://", host, ":", port))
61 if err != nil {
62 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
63 flag.Usage()
64 }
65 }
66
67 cmd := flag.Arg(0)
68 var err error
69 if useHttp {
70 trans, err = thrift.NewTHttpClient(parsedUrl.String())
71 } else {
72 portStr := fmt.Sprint(port)
73 if strings.Contains(host, ":") {
74 host, portStr, err = net.SplitHostPort(host)
75 if err != nil {
76 fmt.Fprintln(os.Stderr, "error with host:", err)
77 os.Exit(1)
78 }
79 }
80 trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
81 if err != nil {
82 fmt.Fprintln(os.Stderr, "error resolving address:", err)
83 os.Exit(1)
84 }
85 if framed {
86 trans = thrift.NewTFramedTransport(trans)
87 }
88 }
89 if err != nil {
90 fmt.Fprintln(os.Stderr, "Error creating transport", err)
91 os.Exit(1)
92 }
93 defer trans.Close()
94 var protocolFactory thrift.TProtocolFactory
95 switch protocol {
96 case "compact":
97 protocolFactory = thrift.NewTCompactProtocolFactory()
98 break
99 case "simplejson":
100 protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
101 break
102 case "json":
103 protocolFactory = thrift.NewTJSONProtocolFactory()
104 break
105 case "binary", "":
106 protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
107 break
108 default:
109 fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
110 Usage()
111 os.Exit(1)
112 }
113 client := zipkincollector.NewZipkinCollectorClientFactory(trans, protocolFactory)
114 if err := trans.Open(); err != nil {
115 fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
116 os.Exit(1)
117 }
118
119 switch cmd {
120 case "storeTopAnnotations":
121 if flag.NArg()-1 != 2 {
122 fmt.Fprintln(os.Stderr, "StoreTopAnnotations requires 2 args")
123 flag.Usage()
124 }
125 argvalue0 := flag.Arg(1)
126 value0 := argvalue0
127 arg10 := flag.Arg(2)
128 mbTrans11 := thrift.NewTMemoryBufferLen(len(arg10))
129 defer mbTrans11.Close()
130 _, err12 := mbTrans11.WriteString(arg10)
131 if err12 != nil {
132 Usage()
133 return
134 }
135 factory13 := thrift.NewTSimpleJSONProtocolFactory()
136 jsProt14 := factory13.GetProtocol(mbTrans11)
137 containerStruct1 := zipkincollector.NewStoreTopAnnotationsArgs()
138 err15 := containerStruct1.ReadField2(jsProt14)
139 if err15 != nil {
140 Usage()
141 return
142 }
143 argvalue1 := containerStruct1.Annotations
144 value1 := argvalue1
145 fmt.Print(client.StoreTopAnnotations(value0, value1))
146 fmt.Print("\n")
147 break
148 case "storeTopKeyValueAnnotations":
149 if flag.NArg()-1 != 2 {
150 fmt.Fprintln(os.Stderr, "StoreTopKeyValueAnnotations requires 2 args")
151 flag.Usage()
152 }
153 argvalue0 := flag.Arg(1)
154 value0 := argvalue0
155 arg17 := flag.Arg(2)
156 mbTrans18 := thrift.NewTMemoryBufferLen(len(arg17))
157 defer mbTrans18.Close()
158 _, err19 := mbTrans18.WriteString(arg17)
159 if err19 != nil {
160 Usage()
161 return
162 }
163 factory20 := thrift.NewTSimpleJSONProtocolFactory()
164 jsProt21 := factory20.GetProtocol(mbTrans18)
165 containerStruct1 := zipkincollector.NewStoreTopKeyValueAnnotationsArgs()
166 err22 := containerStruct1.ReadField2(jsProt21)
167 if err22 != nil {
168 Usage()
169 return
170 }
171 argvalue1 := containerStruct1.Annotations
172 value1 := argvalue1
173 fmt.Print(client.StoreTopKeyValueAnnotations(value0, value1))
174 fmt.Print("\n")
175 break
176 case "storeDependencies":
177 if flag.NArg()-1 != 1 {
178 fmt.Fprintln(os.Stderr, "StoreDependencies requires 1 args")
179 flag.Usage()
180 }
181 arg23 := flag.Arg(1)
182 mbTrans24 := thrift.NewTMemoryBufferLen(len(arg23))
183 defer mbTrans24.Close()
184 _, err25 := mbTrans24.WriteString(arg23)
185 if err25 != nil {
186 Usage()
187 return
188 }
189 factory26 := thrift.NewTSimpleJSONProtocolFactory()
190 jsProt27 := factory26.GetProtocol(mbTrans24)
191 argvalue0 := zipkincollector.NewDependencies()
192 err28 := argvalue0.Read(jsProt27)
193 if err28 != nil {
194 Usage()
195 return
196 }
197 value0 := argvalue0
198 fmt.Print(client.StoreDependencies(value0))
199 fmt.Print("\n")
200 break
201 case "Log":
202 if flag.NArg()-1 != 1 {
203 fmt.Fprintln(os.Stderr, "Log requires 1 args")
204 flag.Usage()
205 }
206 arg29 := flag.Arg(1)
207 mbTrans30 := thrift.NewTMemoryBufferLen(len(arg29))
208 defer mbTrans30.Close()
209 _, err31 := mbTrans30.WriteString(arg29)
210 if err31 != nil {
211 Usage()
212 return
213 }
214 factory32 := thrift.NewTSimpleJSONProtocolFactory()
215 jsProt33 := factory32.GetProtocol(mbTrans30)
216 containerStruct0 := zipkincollector.NewLogArgs()
217 err34 := containerStruct0.ReadField1(jsProt33)
218 if err34 != nil {
219 Usage()
220 return
221 }
222 argvalue0 := containerStruct0.Messages
223 value0 := argvalue0
224 fmt.Print(client.Log(value0))
225 fmt.Print("\n")
226 break
227 case "":
228 Usage()
229 break
230 default:
231 fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
232 }
233 }
+0
-1112
tracing/zipkin/_thrift/gen-go/zipkincollector/zipkincollector.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package zipkincollector
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 "scribe"
10 "zipkindependencies"
11 )
12
13 // (needed to ensure safety because of naive import list construction.)
14 var _ = thrift.ZERO
15 var _ = fmt.Printf
16 var _ = bytes.Equal
17
18 var _ = scribe.GoUnusedProtection__
19 var _ = zipkindependencies.GoUnusedProtection__
20
21 type ZipkinCollector interface {
22 scribe.Scribe
23
24 // Aggregates methods
25 //
26 // Parameters:
27 // - ServiceName
28 // - Annotations
29 StoreTopAnnotations(service_name string, annotations []string) (err error)
30 // Parameters:
31 // - ServiceName
32 // - Annotations
33 StoreTopKeyValueAnnotations(service_name string, annotations []string) (err error)
34 // Parameters:
35 // - Dependencies
36 StoreDependencies(dependencies *zipkindependencies.Dependencies) (err error)
37 }
38
39 type ZipkinCollectorClient struct {
40 *scribe.ScribeClient
41 }
42
43 func NewZipkinCollectorClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ZipkinCollectorClient {
44 return &ZipkinCollectorClient{ScribeClient: scribe.NewScribeClientFactory(t, f)}
45 }
46
47 func NewZipkinCollectorClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ZipkinCollectorClient {
48 return &ZipkinCollectorClient{ScribeClient: scribe.NewScribeClientProtocol(t, iprot, oprot)}
49 }
50
51 // Aggregates methods
52 //
53 // Parameters:
54 // - ServiceName
55 // - Annotations
56 func (p *ZipkinCollectorClient) StoreTopAnnotations(service_name string, annotations []string) (err error) {
57 if err = p.sendStoreTopAnnotations(service_name, annotations); err != nil {
58 return
59 }
60 return p.recvStoreTopAnnotations()
61 }
62
63 func (p *ZipkinCollectorClient) sendStoreTopAnnotations(service_name string, annotations []string) (err error) {
64 oprot := p.OutputProtocol
65 if oprot == nil {
66 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
67 p.OutputProtocol = oprot
68 }
69 p.SeqId++
70 if err = oprot.WriteMessageBegin("storeTopAnnotations", thrift.CALL, p.SeqId); err != nil {
71 return
72 }
73 args := StoreTopAnnotationsArgs{
74 ServiceName: service_name,
75 Annotations: annotations,
76 }
77 if err = args.Write(oprot); err != nil {
78 return
79 }
80 if err = oprot.WriteMessageEnd(); err != nil {
81 return
82 }
83 return oprot.Flush()
84 }
85
86 func (p *ZipkinCollectorClient) recvStoreTopAnnotations() (err error) {
87 iprot := p.InputProtocol
88 if iprot == nil {
89 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
90 p.InputProtocol = iprot
91 }
92 _, mTypeId, seqId, err := iprot.ReadMessageBegin()
93 if err != nil {
94 return
95 }
96 if mTypeId == thrift.EXCEPTION {
97 error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
98 var error1 error
99 error1, err = error0.Read(iprot)
100 if err != nil {
101 return
102 }
103 if err = iprot.ReadMessageEnd(); err != nil {
104 return
105 }
106 err = error1
107 return
108 }
109 if p.SeqId != seqId {
110 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "storeTopAnnotations failed: out of sequence response")
111 return
112 }
113 result := StoreTopAnnotationsResult{}
114 if err = result.Read(iprot); err != nil {
115 return
116 }
117 if err = iprot.ReadMessageEnd(); err != nil {
118 return
119 }
120 if result.E != nil {
121 err = result.E
122 return
123 }
124 return
125 }
126
127 // Parameters:
128 // - ServiceName
129 // - Annotations
130 func (p *ZipkinCollectorClient) StoreTopKeyValueAnnotations(service_name string, annotations []string) (err error) {
131 if err = p.sendStoreTopKeyValueAnnotations(service_name, annotations); err != nil {
132 return
133 }
134 return p.recvStoreTopKeyValueAnnotations()
135 }
136
137 func (p *ZipkinCollectorClient) sendStoreTopKeyValueAnnotations(service_name string, annotations []string) (err error) {
138 oprot := p.OutputProtocol
139 if oprot == nil {
140 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
141 p.OutputProtocol = oprot
142 }
143 p.SeqId++
144 if err = oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.CALL, p.SeqId); err != nil {
145 return
146 }
147 args := StoreTopKeyValueAnnotationsArgs{
148 ServiceName: service_name,
149 Annotations: annotations,
150 }
151 if err = args.Write(oprot); err != nil {
152 return
153 }
154 if err = oprot.WriteMessageEnd(); err != nil {
155 return
156 }
157 return oprot.Flush()
158 }
159
160 func (p *ZipkinCollectorClient) recvStoreTopKeyValueAnnotations() (err error) {
161 iprot := p.InputProtocol
162 if iprot == nil {
163 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
164 p.InputProtocol = iprot
165 }
166 _, mTypeId, seqId, err := iprot.ReadMessageBegin()
167 if err != nil {
168 return
169 }
170 if mTypeId == thrift.EXCEPTION {
171 error2 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
172 var error3 error
173 error3, err = error2.Read(iprot)
174 if err != nil {
175 return
176 }
177 if err = iprot.ReadMessageEnd(); err != nil {
178 return
179 }
180 err = error3
181 return
182 }
183 if p.SeqId != seqId {
184 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "storeTopKeyValueAnnotations failed: out of sequence response")
185 return
186 }
187 result := StoreTopKeyValueAnnotationsResult{}
188 if err = result.Read(iprot); err != nil {
189 return
190 }
191 if err = iprot.ReadMessageEnd(); err != nil {
192 return
193 }
194 if result.E != nil {
195 err = result.E
196 return
197 }
198 return
199 }
200
201 // Parameters:
202 // - Dependencies
203 func (p *ZipkinCollectorClient) StoreDependencies(dependencies *zipkindependencies.Dependencies) (err error) {
204 if err = p.sendStoreDependencies(dependencies); err != nil {
205 return
206 }
207 return p.recvStoreDependencies()
208 }
209
210 func (p *ZipkinCollectorClient) sendStoreDependencies(dependencies *zipkindependencies.Dependencies) (err error) {
211 oprot := p.OutputProtocol
212 if oprot == nil {
213 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
214 p.OutputProtocol = oprot
215 }
216 p.SeqId++
217 if err = oprot.WriteMessageBegin("storeDependencies", thrift.CALL, p.SeqId); err != nil {
218 return
219 }
220 args := StoreDependenciesArgs{
221 Dependencies: dependencies,
222 }
223 if err = args.Write(oprot); err != nil {
224 return
225 }
226 if err = oprot.WriteMessageEnd(); err != nil {
227 return
228 }
229 return oprot.Flush()
230 }
231
232 func (p *ZipkinCollectorClient) recvStoreDependencies() (err error) {
233 iprot := p.InputProtocol
234 if iprot == nil {
235 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
236 p.InputProtocol = iprot
237 }
238 _, mTypeId, seqId, err := iprot.ReadMessageBegin()
239 if err != nil {
240 return
241 }
242 if mTypeId == thrift.EXCEPTION {
243 error4 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
244 var error5 error
245 error5, err = error4.Read(iprot)
246 if err != nil {
247 return
248 }
249 if err = iprot.ReadMessageEnd(); err != nil {
250 return
251 }
252 err = error5
253 return
254 }
255 if p.SeqId != seqId {
256 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "storeDependencies failed: out of sequence response")
257 return
258 }
259 result := StoreDependenciesResult{}
260 if err = result.Read(iprot); err != nil {
261 return
262 }
263 if err = iprot.ReadMessageEnd(); err != nil {
264 return
265 }
266 if result.E != nil {
267 err = result.E
268 return
269 }
270 return
271 }
272
273 type ZipkinCollectorProcessor struct {
274 *scribe.ScribeProcessor
275 }
276
277 func NewZipkinCollectorProcessor(handler ZipkinCollector) *ZipkinCollectorProcessor {
278 self6 := &ZipkinCollectorProcessor{scribe.NewScribeProcessor(handler)}
279 self6.AddToProcessorMap("storeTopAnnotations", &zipkinCollectorProcessorStoreTopAnnotations{handler: handler})
280 self6.AddToProcessorMap("storeTopKeyValueAnnotations", &zipkinCollectorProcessorStoreTopKeyValueAnnotations{handler: handler})
281 self6.AddToProcessorMap("storeDependencies", &zipkinCollectorProcessorStoreDependencies{handler: handler})
282 return self6
283 }
284
285 type zipkinCollectorProcessorStoreTopAnnotations struct {
286 handler ZipkinCollector
287 }
288
289 func (p *zipkinCollectorProcessorStoreTopAnnotations) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
290 args := StoreTopAnnotationsArgs{}
291 if err = args.Read(iprot); err != nil {
292 iprot.ReadMessageEnd()
293 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
294 oprot.WriteMessageBegin("storeTopAnnotations", thrift.EXCEPTION, seqId)
295 x.Write(oprot)
296 oprot.WriteMessageEnd()
297 oprot.Flush()
298 return false, err
299 }
300
301 iprot.ReadMessageEnd()
302 result := StoreTopAnnotationsResult{}
303 var err2 error
304 if err2 = p.handler.StoreTopAnnotations(args.ServiceName, args.Annotations); err2 != nil {
305 switch v := err2.(type) {
306 case *StoreAggregatesException:
307 result.E = v
308 default:
309 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing storeTopAnnotations: "+err2.Error())
310 oprot.WriteMessageBegin("storeTopAnnotations", thrift.EXCEPTION, seqId)
311 x.Write(oprot)
312 oprot.WriteMessageEnd()
313 oprot.Flush()
314 return true, err2
315 }
316 }
317 if err2 = oprot.WriteMessageBegin("storeTopAnnotations", thrift.REPLY, seqId); err2 != nil {
318 err = err2
319 }
320 if err2 = result.Write(oprot); err == nil && err2 != nil {
321 err = err2
322 }
323 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
324 err = err2
325 }
326 if err2 = oprot.Flush(); err == nil && err2 != nil {
327 err = err2
328 }
329 if err != nil {
330 return
331 }
332 return true, err
333 }
334
335 type zipkinCollectorProcessorStoreTopKeyValueAnnotations struct {
336 handler ZipkinCollector
337 }
338
339 func (p *zipkinCollectorProcessorStoreTopKeyValueAnnotations) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
340 args := StoreTopKeyValueAnnotationsArgs{}
341 if err = args.Read(iprot); err != nil {
342 iprot.ReadMessageEnd()
343 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
344 oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.EXCEPTION, seqId)
345 x.Write(oprot)
346 oprot.WriteMessageEnd()
347 oprot.Flush()
348 return false, err
349 }
350
351 iprot.ReadMessageEnd()
352 result := StoreTopKeyValueAnnotationsResult{}
353 var err2 error
354 if err2 = p.handler.StoreTopKeyValueAnnotations(args.ServiceName, args.Annotations); err2 != nil {
355 switch v := err2.(type) {
356 case *StoreAggregatesException:
357 result.E = v
358 default:
359 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing storeTopKeyValueAnnotations: "+err2.Error())
360 oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.EXCEPTION, seqId)
361 x.Write(oprot)
362 oprot.WriteMessageEnd()
363 oprot.Flush()
364 return true, err2
365 }
366 }
367 if err2 = oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.REPLY, seqId); err2 != nil {
368 err = err2
369 }
370 if err2 = result.Write(oprot); err == nil && err2 != nil {
371 err = err2
372 }
373 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
374 err = err2
375 }
376 if err2 = oprot.Flush(); err == nil && err2 != nil {
377 err = err2
378 }
379 if err != nil {
380 return
381 }
382 return true, err
383 }
384
385 type zipkinCollectorProcessorStoreDependencies struct {
386 handler ZipkinCollector
387 }
388
389 func (p *zipkinCollectorProcessorStoreDependencies) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
390 args := StoreDependenciesArgs{}
391 if err = args.Read(iprot); err != nil {
392 iprot.ReadMessageEnd()
393 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
394 oprot.WriteMessageBegin("storeDependencies", thrift.EXCEPTION, seqId)
395 x.Write(oprot)
396 oprot.WriteMessageEnd()
397 oprot.Flush()
398 return false, err
399 }
400
401 iprot.ReadMessageEnd()
402 result := StoreDependenciesResult{}
403 var err2 error
404 if err2 = p.handler.StoreDependencies(args.Dependencies); err2 != nil {
405 switch v := err2.(type) {
406 case *StoreAggregatesException:
407 result.E = v
408 default:
409 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing storeDependencies: "+err2.Error())
410 oprot.WriteMessageBegin("storeDependencies", thrift.EXCEPTION, seqId)
411 x.Write(oprot)
412 oprot.WriteMessageEnd()
413 oprot.Flush()
414 return true, err2
415 }
416 }
417 if err2 = oprot.WriteMessageBegin("storeDependencies", thrift.REPLY, seqId); err2 != nil {
418 err = err2
419 }
420 if err2 = result.Write(oprot); err == nil && err2 != nil {
421 err = err2
422 }
423 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
424 err = err2
425 }
426 if err2 = oprot.Flush(); err == nil && err2 != nil {
427 err = err2
428 }
429 if err != nil {
430 return
431 }
432 return true, err
433 }
434
435 // HELPER FUNCTIONS AND STRUCTURES
436
437 type StoreTopAnnotationsArgs struct {
438 ServiceName string `thrift:"service_name,1" json:"service_name"`
439 Annotations []string `thrift:"annotations,2" json:"annotations"`
440 }
441
442 func NewStoreTopAnnotationsArgs() *StoreTopAnnotationsArgs {
443 return &StoreTopAnnotationsArgs{}
444 }
445
446 func (p *StoreTopAnnotationsArgs) GetServiceName() string {
447 return p.ServiceName
448 }
449
450 func (p *StoreTopAnnotationsArgs) GetAnnotations() []string {
451 return p.Annotations
452 }
453 func (p *StoreTopAnnotationsArgs) Read(iprot thrift.TProtocol) error {
454 if _, err := iprot.ReadStructBegin(); err != nil {
455 return fmt.Errorf("%T read error: %s", p, err)
456 }
457 for {
458 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
459 if err != nil {
460 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
461 }
462 if fieldTypeId == thrift.STOP {
463 break
464 }
465 switch fieldId {
466 case 1:
467 if err := p.ReadField1(iprot); err != nil {
468 return err
469 }
470 case 2:
471 if err := p.ReadField2(iprot); err != nil {
472 return err
473 }
474 default:
475 if err := iprot.Skip(fieldTypeId); err != nil {
476 return err
477 }
478 }
479 if err := iprot.ReadFieldEnd(); err != nil {
480 return err
481 }
482 }
483 if err := iprot.ReadStructEnd(); err != nil {
484 return fmt.Errorf("%T read struct end error: %s", p, err)
485 }
486 return nil
487 }
488
489 func (p *StoreTopAnnotationsArgs) ReadField1(iprot thrift.TProtocol) error {
490 if v, err := iprot.ReadString(); err != nil {
491 return fmt.Errorf("error reading field 1: %s", err)
492 } else {
493 p.ServiceName = v
494 }
495 return nil
496 }
497
498 func (p *StoreTopAnnotationsArgs) ReadField2(iprot thrift.TProtocol) error {
499 _, size, err := iprot.ReadListBegin()
500 if err != nil {
501 return fmt.Errorf("error reading list begin: %s", err)
502 }
503 tSlice := make([]string, 0, size)
504 p.Annotations = tSlice
505 for i := 0; i < size; i++ {
506 var _elem7 string
507 if v, err := iprot.ReadString(); err != nil {
508 return fmt.Errorf("error reading field 0: %s", err)
509 } else {
510 _elem7 = v
511 }
512 p.Annotations = append(p.Annotations, _elem7)
513 }
514 if err := iprot.ReadListEnd(); err != nil {
515 return fmt.Errorf("error reading list end: %s", err)
516 }
517 return nil
518 }
519
520 func (p *StoreTopAnnotationsArgs) Write(oprot thrift.TProtocol) error {
521 if err := oprot.WriteStructBegin("storeTopAnnotations_args"); err != nil {
522 return fmt.Errorf("%T write struct begin error: %s", p, err)
523 }
524 if err := p.writeField1(oprot); err != nil {
525 return err
526 }
527 if err := p.writeField2(oprot); err != nil {
528 return err
529 }
530 if err := oprot.WriteFieldStop(); err != nil {
531 return fmt.Errorf("write field stop error: %s", err)
532 }
533 if err := oprot.WriteStructEnd(); err != nil {
534 return fmt.Errorf("write struct stop error: %s", err)
535 }
536 return nil
537 }
538
539 func (p *StoreTopAnnotationsArgs) writeField1(oprot thrift.TProtocol) (err error) {
540 if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil {
541 return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err)
542 }
543 if err := oprot.WriteString(string(p.ServiceName)); err != nil {
544 return fmt.Errorf("%T.service_name (1) field write error: %s", p, err)
545 }
546 if err := oprot.WriteFieldEnd(); err != nil {
547 return fmt.Errorf("%T write field end error 1:service_name: %s", p, err)
548 }
549 return err
550 }
551
552 func (p *StoreTopAnnotationsArgs) writeField2(oprot thrift.TProtocol) (err error) {
553 if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 2); err != nil {
554 return fmt.Errorf("%T write field begin error 2:annotations: %s", p, err)
555 }
556 if err := oprot.WriteListBegin(thrift.STRING, len(p.Annotations)); err != nil {
557 return fmt.Errorf("error writing list begin: %s", err)
558 }
559 for _, v := range p.Annotations {
560 if err := oprot.WriteString(string(v)); err != nil {
561 return fmt.Errorf("%T. (0) field write error: %s", p, err)
562 }
563 }
564 if err := oprot.WriteListEnd(); err != nil {
565 return fmt.Errorf("error writing list end: %s", err)
566 }
567 if err := oprot.WriteFieldEnd(); err != nil {
568 return fmt.Errorf("%T write field end error 2:annotations: %s", p, err)
569 }
570 return err
571 }
572
573 func (p *StoreTopAnnotationsArgs) String() string {
574 if p == nil {
575 return "<nil>"
576 }
577 return fmt.Sprintf("StoreTopAnnotationsArgs(%+v)", *p)
578 }
579
580 type StoreTopAnnotationsResult struct {
581 E *StoreAggregatesException `thrift:"e,1" json:"e"`
582 }
583
584 func NewStoreTopAnnotationsResult() *StoreTopAnnotationsResult {
585 return &StoreTopAnnotationsResult{}
586 }
587
588 var StoreTopAnnotationsResult_E_DEFAULT *StoreAggregatesException
589
590 func (p *StoreTopAnnotationsResult) GetE() *StoreAggregatesException {
591 if !p.IsSetE() {
592 return StoreTopAnnotationsResult_E_DEFAULT
593 }
594 return p.E
595 }
596 func (p *StoreTopAnnotationsResult) IsSetE() bool {
597 return p.E != nil
598 }
599
600 func (p *StoreTopAnnotationsResult) Read(iprot thrift.TProtocol) error {
601 if _, err := iprot.ReadStructBegin(); err != nil {
602 return fmt.Errorf("%T read error: %s", p, err)
603 }
604 for {
605 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
606 if err != nil {
607 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
608 }
609 if fieldTypeId == thrift.STOP {
610 break
611 }
612 switch fieldId {
613 case 1:
614 if err := p.ReadField1(iprot); err != nil {
615 return err
616 }
617 default:
618 if err := iprot.Skip(fieldTypeId); err != nil {
619 return err
620 }
621 }
622 if err := iprot.ReadFieldEnd(); err != nil {
623 return err
624 }
625 }
626 if err := iprot.ReadStructEnd(); err != nil {
627 return fmt.Errorf("%T read struct end error: %s", p, err)
628 }
629 return nil
630 }
631
632 func (p *StoreTopAnnotationsResult) ReadField1(iprot thrift.TProtocol) error {
633 p.E = &StoreAggregatesException{}
634 if err := p.E.Read(iprot); err != nil {
635 return fmt.Errorf("%T error reading struct: %s", p.E, err)
636 }
637 return nil
638 }
639
640 func (p *StoreTopAnnotationsResult) Write(oprot thrift.TProtocol) error {
641 if err := oprot.WriteStructBegin("storeTopAnnotations_result"); err != nil {
642 return fmt.Errorf("%T write struct begin error: %s", p, err)
643 }
644 if err := p.writeField1(oprot); err != nil {
645 return err
646 }
647 if err := oprot.WriteFieldStop(); err != nil {
648 return fmt.Errorf("write field stop error: %s", err)
649 }
650 if err := oprot.WriteStructEnd(); err != nil {
651 return fmt.Errorf("write struct stop error: %s", err)
652 }
653 return nil
654 }
655
656 func (p *StoreTopAnnotationsResult) writeField1(oprot thrift.TProtocol) (err error) {
657 if p.IsSetE() {
658 if err := oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil {
659 return fmt.Errorf("%T write field begin error 1:e: %s", p, err)
660 }
661 if err := p.E.Write(oprot); err != nil {
662 return fmt.Errorf("%T error writing struct: %s", p.E, err)
663 }
664 if err := oprot.WriteFieldEnd(); err != nil {
665 return fmt.Errorf("%T write field end error 1:e: %s", p, err)
666 }
667 }
668 return err
669 }
670
671 func (p *StoreTopAnnotationsResult) String() string {
672 if p == nil {
673 return "<nil>"
674 }
675 return fmt.Sprintf("StoreTopAnnotationsResult(%+v)", *p)
676 }
677
678 type StoreTopKeyValueAnnotationsArgs struct {
679 ServiceName string `thrift:"service_name,1" json:"service_name"`
680 Annotations []string `thrift:"annotations,2" json:"annotations"`
681 }
682
683 func NewStoreTopKeyValueAnnotationsArgs() *StoreTopKeyValueAnnotationsArgs {
684 return &StoreTopKeyValueAnnotationsArgs{}
685 }
686
687 func (p *StoreTopKeyValueAnnotationsArgs) GetServiceName() string {
688 return p.ServiceName
689 }
690
691 func (p *StoreTopKeyValueAnnotationsArgs) GetAnnotations() []string {
692 return p.Annotations
693 }
694 func (p *StoreTopKeyValueAnnotationsArgs) Read(iprot thrift.TProtocol) error {
695 if _, err := iprot.ReadStructBegin(); err != nil {
696 return fmt.Errorf("%T read error: %s", p, err)
697 }
698 for {
699 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
700 if err != nil {
701 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
702 }
703 if fieldTypeId == thrift.STOP {
704 break
705 }
706 switch fieldId {
707 case 1:
708 if err := p.ReadField1(iprot); err != nil {
709 return err
710 }
711 case 2:
712 if err := p.ReadField2(iprot); err != nil {
713 return err
714 }
715 default:
716 if err := iprot.Skip(fieldTypeId); err != nil {
717 return err
718 }
719 }
720 if err := iprot.ReadFieldEnd(); err != nil {
721 return err
722 }
723 }
724 if err := iprot.ReadStructEnd(); err != nil {
725 return fmt.Errorf("%T read struct end error: %s", p, err)
726 }
727 return nil
728 }
729
730 func (p *StoreTopKeyValueAnnotationsArgs) ReadField1(iprot thrift.TProtocol) error {
731 if v, err := iprot.ReadString(); err != nil {
732 return fmt.Errorf("error reading field 1: %s", err)
733 } else {
734 p.ServiceName = v
735 }
736 return nil
737 }
738
739 func (p *StoreTopKeyValueAnnotationsArgs) ReadField2(iprot thrift.TProtocol) error {
740 _, size, err := iprot.ReadListBegin()
741 if err != nil {
742 return fmt.Errorf("error reading list begin: %s", err)
743 }
744 tSlice := make([]string, 0, size)
745 p.Annotations = tSlice
746 for i := 0; i < size; i++ {
747 var _elem8 string
748 if v, err := iprot.ReadString(); err != nil {
749 return fmt.Errorf("error reading field 0: %s", err)
750 } else {
751 _elem8 = v
752 }
753 p.Annotations = append(p.Annotations, _elem8)
754 }
755 if err := iprot.ReadListEnd(); err != nil {
756 return fmt.Errorf("error reading list end: %s", err)
757 }
758 return nil
759 }
760
761 func (p *StoreTopKeyValueAnnotationsArgs) Write(oprot thrift.TProtocol) error {
762 if err := oprot.WriteStructBegin("storeTopKeyValueAnnotations_args"); err != nil {
763 return fmt.Errorf("%T write struct begin error: %s", p, err)
764 }
765 if err := p.writeField1(oprot); err != nil {
766 return err
767 }
768 if err := p.writeField2(oprot); err != nil {
769 return err
770 }
771 if err := oprot.WriteFieldStop(); err != nil {
772 return fmt.Errorf("write field stop error: %s", err)
773 }
774 if err := oprot.WriteStructEnd(); err != nil {
775 return fmt.Errorf("write struct stop error: %s", err)
776 }
777 return nil
778 }
779
780 func (p *StoreTopKeyValueAnnotationsArgs) writeField1(oprot thrift.TProtocol) (err error) {
781 if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil {
782 return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err)
783 }
784 if err := oprot.WriteString(string(p.ServiceName)); err != nil {
785 return fmt.Errorf("%T.service_name (1) field write error: %s", p, err)
786 }
787 if err := oprot.WriteFieldEnd(); err != nil {
788 return fmt.Errorf("%T write field end error 1:service_name: %s", p, err)
789 }
790 return err
791 }
792
793 func (p *StoreTopKeyValueAnnotationsArgs) writeField2(oprot thrift.TProtocol) (err error) {
794 if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 2); err != nil {
795 return fmt.Errorf("%T write field begin error 2:annotations: %s", p, err)
796 }
797 if err := oprot.WriteListBegin(thrift.STRING, len(p.Annotations)); err != nil {
798 return fmt.Errorf("error writing list begin: %s", err)
799 }
800 for _, v := range p.Annotations {
801 if err := oprot.WriteString(string(v)); err != nil {
802 return fmt.Errorf("%T. (0) field write error: %s", p, err)
803 }
804 }
805 if err := oprot.WriteListEnd(); err != nil {
806 return fmt.Errorf("error writing list end: %s", err)
807 }
808 if err := oprot.WriteFieldEnd(); err != nil {
809 return fmt.Errorf("%T write field end error 2:annotations: %s", p, err)
810 }
811 return err
812 }
813
814 func (p *StoreTopKeyValueAnnotationsArgs) String() string {
815 if p == nil {
816 return "<nil>"
817 }
818 return fmt.Sprintf("StoreTopKeyValueAnnotationsArgs(%+v)", *p)
819 }
820
821 type StoreTopKeyValueAnnotationsResult struct {
822 E *StoreAggregatesException `thrift:"e,1" json:"e"`
823 }
824
825 func NewStoreTopKeyValueAnnotationsResult() *StoreTopKeyValueAnnotationsResult {
826 return &StoreTopKeyValueAnnotationsResult{}
827 }
828
829 var StoreTopKeyValueAnnotationsResult_E_DEFAULT *StoreAggregatesException
830
831 func (p *StoreTopKeyValueAnnotationsResult) GetE() *StoreAggregatesException {
832 if !p.IsSetE() {
833 return StoreTopKeyValueAnnotationsResult_E_DEFAULT
834 }
835 return p.E
836 }
837 func (p *StoreTopKeyValueAnnotationsResult) IsSetE() bool {
838 return p.E != nil
839 }
840
841 func (p *StoreTopKeyValueAnnotationsResult) Read(iprot thrift.TProtocol) error {
842 if _, err := iprot.ReadStructBegin(); err != nil {
843 return fmt.Errorf("%T read error: %s", p, err)
844 }
845 for {
846 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
847 if err != nil {
848 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
849 }
850 if fieldTypeId == thrift.STOP {
851 break
852 }
853 switch fieldId {
854 case 1:
855 if err := p.ReadField1(iprot); err != nil {
856 return err
857 }
858 default:
859 if err := iprot.Skip(fieldTypeId); err != nil {
860 return err
861 }
862 }
863 if err := iprot.ReadFieldEnd(); err != nil {
864 return err
865 }
866 }
867 if err := iprot.ReadStructEnd(); err != nil {
868 return fmt.Errorf("%T read struct end error: %s", p, err)
869 }
870 return nil
871 }
872
873 func (p *StoreTopKeyValueAnnotationsResult) ReadField1(iprot thrift.TProtocol) error {
874 p.E = &StoreAggregatesException{}
875 if err := p.E.Read(iprot); err != nil {
876 return fmt.Errorf("%T error reading struct: %s", p.E, err)
877 }
878 return nil
879 }
880
881 func (p *StoreTopKeyValueAnnotationsResult) Write(oprot thrift.TProtocol) error {
882 if err := oprot.WriteStructBegin("storeTopKeyValueAnnotations_result"); err != nil {
883 return fmt.Errorf("%T write struct begin error: %s", p, err)
884 }
885 if err := p.writeField1(oprot); err != nil {
886 return err
887 }
888 if err := oprot.WriteFieldStop(); err != nil {
889 return fmt.Errorf("write field stop error: %s", err)
890 }
891 if err := oprot.WriteStructEnd(); err != nil {
892 return fmt.Errorf("write struct stop error: %s", err)
893 }
894 return nil
895 }
896
897 func (p *StoreTopKeyValueAnnotationsResult) writeField1(oprot thrift.TProtocol) (err error) {
898 if p.IsSetE() {
899 if err := oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil {
900 return fmt.Errorf("%T write field begin error 1:e: %s", p, err)
901 }
902 if err := p.E.Write(oprot); err != nil {
903 return fmt.Errorf("%T error writing struct: %s", p.E, err)
904 }
905 if err := oprot.WriteFieldEnd(); err != nil {
906 return fmt.Errorf("%T write field end error 1:e: %s", p, err)
907 }
908 }
909 return err
910 }
911
912 func (p *StoreTopKeyValueAnnotationsResult) String() string {
913 if p == nil {
914 return "<nil>"
915 }
916 return fmt.Sprintf("StoreTopKeyValueAnnotationsResult(%+v)", *p)
917 }
918
919 type StoreDependenciesArgs struct {
920 Dependencies *zipkindependencies.Dependencies `thrift:"dependencies,1" json:"dependencies"`
921 }
922
923 func NewStoreDependenciesArgs() *StoreDependenciesArgs {
924 return &StoreDependenciesArgs{}
925 }
926
927 var StoreDependenciesArgs_Dependencies_DEFAULT *zipkindependencies.Dependencies
928
929 func (p *StoreDependenciesArgs) GetDependencies() *zipkindependencies.Dependencies {
930 if !p.IsSetDependencies() {
931 return StoreDependenciesArgs_Dependencies_DEFAULT
932 }
933 return p.Dependencies
934 }
935 func (p *StoreDependenciesArgs) IsSetDependencies() bool {
936 return p.Dependencies != nil
937 }
938
939 func (p *StoreDependenciesArgs) Read(iprot thrift.TProtocol) error {
940 if _, err := iprot.ReadStructBegin(); err != nil {
941 return fmt.Errorf("%T read error: %s", p, err)
942 }
943 for {
944 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
945 if err != nil {
946 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
947 }
948 if fieldTypeId == thrift.STOP {
949 break
950 }
951 switch fieldId {
952 case 1:
953 if err := p.ReadField1(iprot); err != nil {
954 return err
955 }
956 default:
957 if err := iprot.Skip(fieldTypeId); err != nil {
958 return err
959 }
960 }
961 if err := iprot.ReadFieldEnd(); err != nil {
962 return err
963 }
964 }
965 if err := iprot.ReadStructEnd(); err != nil {
966 return fmt.Errorf("%T read struct end error: %s", p, err)
967 }
968 return nil
969 }
970
971 func (p *StoreDependenciesArgs) ReadField1(iprot thrift.TProtocol) error {
972 p.Dependencies = &zipkindependencies.Dependencies{}
973 if err := p.Dependencies.Read(iprot); err != nil {
974 return fmt.Errorf("%T error reading struct: %s", p.Dependencies, err)
975 }
976 return nil
977 }
978
979 func (p *StoreDependenciesArgs) Write(oprot thrift.TProtocol) error {
980 if err := oprot.WriteStructBegin("storeDependencies_args"); err != nil {
981 return fmt.Errorf("%T write struct begin error: %s", p, err)
982 }
983 if err := p.writeField1(oprot); err != nil {
984 return err
985 }
986 if err := oprot.WriteFieldStop(); err != nil {
987 return fmt.Errorf("write field stop error: %s", err)
988 }
989 if err := oprot.WriteStructEnd(); err != nil {
990 return fmt.Errorf("write struct stop error: %s", err)
991 }
992 return nil
993 }
994
995 func (p *StoreDependenciesArgs) writeField1(oprot thrift.TProtocol) (err error) {
996 if err := oprot.WriteFieldBegin("dependencies", thrift.STRUCT, 1); err != nil {
997 return fmt.Errorf("%T write field begin error 1:dependencies: %s", p, err)
998 }
999 if err := p.Dependencies.Write(oprot); err != nil {
1000 return fmt.Errorf("%T error writing struct: %s", p.Dependencies, err)
1001 }
1002 if err := oprot.WriteFieldEnd(); err != nil {
1003 return fmt.Errorf("%T write field end error 1:dependencies: %s", p, err)
1004 }
1005 return err
1006 }
1007
1008 func (p *StoreDependenciesArgs) String() string {
1009 if p == nil {
1010 return "<nil>"
1011 }
1012 return fmt.Sprintf("StoreDependenciesArgs(%+v)", *p)
1013 }
1014
1015 type StoreDependenciesResult struct {
1016 E *StoreAggregatesException `thrift:"e,1" json:"e"`
1017 }
1018
1019 func NewStoreDependenciesResult() *StoreDependenciesResult {
1020 return &StoreDependenciesResult{}
1021 }
1022
1023 var StoreDependenciesResult_E_DEFAULT *StoreAggregatesException
1024
1025 func (p *StoreDependenciesResult) GetE() *StoreAggregatesException {
1026 if !p.IsSetE() {
1027 return StoreDependenciesResult_E_DEFAULT
1028 }
1029 return p.E
1030 }
1031 func (p *StoreDependenciesResult) IsSetE() bool {
1032 return p.E != nil
1033 }
1034
1035 func (p *StoreDependenciesResult) Read(iprot thrift.TProtocol) error {
1036 if _, err := iprot.ReadStructBegin(); err != nil {
1037 return fmt.Errorf("%T read error: %s", p, err)
1038 }
1039 for {
1040 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
1041 if err != nil {
1042 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
1043 }
1044 if fieldTypeId == thrift.STOP {
1045 break
1046 }
1047 switch fieldId {
1048 case 1:
1049 if err := p.ReadField1(iprot); err != nil {
1050 return err
1051 }
1052 default:
1053 if err := iprot.Skip(fieldTypeId); err != nil {
1054 return err
1055 }
1056 }
1057 if err := iprot.ReadFieldEnd(); err != nil {
1058 return err
1059 }
1060 }
1061 if err := iprot.ReadStructEnd(); err != nil {
1062 return fmt.Errorf("%T read struct end error: %s", p, err)
1063 }
1064 return nil
1065 }
1066
1067 func (p *StoreDependenciesResult) ReadField1(iprot thrift.TProtocol) error {
1068 p.E = &StoreAggregatesException{}
1069 if err := p.E.Read(iprot); err != nil {
1070 return fmt.Errorf("%T error reading struct: %s", p.E, err)
1071 }
1072 return nil
1073 }
1074
1075 func (p *StoreDependenciesResult) Write(oprot thrift.TProtocol) error {
1076 if err := oprot.WriteStructBegin("storeDependencies_result"); err != nil {
1077 return fmt.Errorf("%T write struct begin error: %s", p, err)
1078 }
1079 if err := p.writeField1(oprot); err != nil {
1080 return err
1081 }
1082 if err := oprot.WriteFieldStop(); err != nil {
1083 return fmt.Errorf("write field stop error: %s", err)
1084 }
1085 if err := oprot.WriteStructEnd(); err != nil {
1086 return fmt.Errorf("write struct stop error: %s", err)
1087 }
1088 return nil
1089 }
1090
1091 func (p *StoreDependenciesResult) writeField1(oprot thrift.TProtocol) (err error) {
1092 if p.IsSetE() {
1093 if err := oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil {
1094 return fmt.Errorf("%T write field begin error 1:e: %s", p, err)
1095 }
1096 if err := p.E.Write(oprot); err != nil {
1097 return fmt.Errorf("%T error writing struct: %s", p.E, err)
1098 }
1099 if err := oprot.WriteFieldEnd(); err != nil {
1100 return fmt.Errorf("%T write field end error 1:e: %s", p, err)
1101 }
1102 }
1103 return err
1104 }
1105
1106 func (p *StoreDependenciesResult) String() string {
1107 if p == nil {
1108 return "<nil>"
1109 }
1110 return fmt.Sprintf("StoreDependenciesResult(%+v)", *p)
1111 }
+0
-23
tracing/zipkin/_thrift/gen-go/zipkincore/constants.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package zipkincore
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf
14 var _ = bytes.Equal
15
16 const CLIENT_SEND = "cs"
17 const CLIENT_RECV = "cr"
18 const SERVER_SEND = "ss"
19 const SERVER_RECV = "sr"
20
21 func init() {
22 }
+0
-990
tracing/zipkin/_thrift/gen-go/zipkincore/ttypes.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package zipkincore
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf
14 var _ = bytes.Equal
15
16 var GoUnusedProtection__ int
17
18 type AnnotationType int64
19
20 const (
21 AnnotationType_BOOL AnnotationType = 0
22 AnnotationType_BYTES AnnotationType = 1
23 AnnotationType_I16 AnnotationType = 2
24 AnnotationType_I32 AnnotationType = 3
25 AnnotationType_I64 AnnotationType = 4
26 AnnotationType_DOUBLE AnnotationType = 5
27 AnnotationType_STRING AnnotationType = 6
28 )
29
30 func (p AnnotationType) String() string {
31 switch p {
32 case AnnotationType_BOOL:
33 return "AnnotationType_BOOL"
34 case AnnotationType_BYTES:
35 return "AnnotationType_BYTES"
36 case AnnotationType_I16:
37 return "AnnotationType_I16"
38 case AnnotationType_I32:
39 return "AnnotationType_I32"
40 case AnnotationType_I64:
41 return "AnnotationType_I64"
42 case AnnotationType_DOUBLE:
43 return "AnnotationType_DOUBLE"
44 case AnnotationType_STRING:
45 return "AnnotationType_STRING"
46 }
47 return "<UNSET>"
48 }
49
50 func AnnotationTypeFromString(s string) (AnnotationType, error) {
51 switch s {
52 case "AnnotationType_BOOL":
53 return AnnotationType_BOOL, nil
54 case "AnnotationType_BYTES":
55 return AnnotationType_BYTES, nil
56 case "AnnotationType_I16":
57 return AnnotationType_I16, nil
58 case "AnnotationType_I32":
59 return AnnotationType_I32, nil
60 case "AnnotationType_I64":
61 return AnnotationType_I64, nil
62 case "AnnotationType_DOUBLE":
63 return AnnotationType_DOUBLE, nil
64 case "AnnotationType_STRING":
65 return AnnotationType_STRING, nil
66 }
67 return AnnotationType(0), fmt.Errorf("not a valid AnnotationType string")
68 }
69
70 func AnnotationTypePtr(v AnnotationType) *AnnotationType { return &v }
71
72 type Endpoint struct {
73 Ipv4 int32 `thrift:"ipv4,1" json:"ipv4"`
74 Port int16 `thrift:"port,2" json:"port"`
75 ServiceName string `thrift:"service_name,3" json:"service_name"`
76 }
77
78 func NewEndpoint() *Endpoint {
79 return &Endpoint{}
80 }
81
82 func (p *Endpoint) GetIpv4() int32 {
83 return p.Ipv4
84 }
85
86 func (p *Endpoint) GetPort() int16 {
87 return p.Port
88 }
89
90 func (p *Endpoint) GetServiceName() string {
91 return p.ServiceName
92 }
93 func (p *Endpoint) Read(iprot thrift.TProtocol) error {
94 if _, err := iprot.ReadStructBegin(); err != nil {
95 return fmt.Errorf("%T read error: %s", p, err)
96 }
97 for {
98 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
99 if err != nil {
100 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
101 }
102 if fieldTypeId == thrift.STOP {
103 break
104 }
105 switch fieldId {
106 case 1:
107 if err := p.ReadField1(iprot); err != nil {
108 return err
109 }
110 case 2:
111 if err := p.ReadField2(iprot); err != nil {
112 return err
113 }
114 case 3:
115 if err := p.ReadField3(iprot); err != nil {
116 return err
117 }
118 default:
119 if err := iprot.Skip(fieldTypeId); err != nil {
120 return err
121 }
122 }
123 if err := iprot.ReadFieldEnd(); err != nil {
124 return err
125 }
126 }
127 if err := iprot.ReadStructEnd(); err != nil {
128 return fmt.Errorf("%T read struct end error: %s", p, err)
129 }
130 return nil
131 }
132
133 func (p *Endpoint) ReadField1(iprot thrift.TProtocol) error {
134 if v, err := iprot.ReadI32(); err != nil {
135 return fmt.Errorf("error reading field 1: %s", err)
136 } else {
137 p.Ipv4 = v
138 }
139 return nil
140 }
141
142 func (p *Endpoint) ReadField2(iprot thrift.TProtocol) error {
143 if v, err := iprot.ReadI16(); err != nil {
144 return fmt.Errorf("error reading field 2: %s", err)
145 } else {
146 p.Port = v
147 }
148 return nil
149 }
150
151 func (p *Endpoint) ReadField3(iprot thrift.TProtocol) error {
152 if v, err := iprot.ReadString(); err != nil {
153 return fmt.Errorf("error reading field 3: %s", err)
154 } else {
155 p.ServiceName = v
156 }
157 return nil
158 }
159
160 func (p *Endpoint) Write(oprot thrift.TProtocol) error {
161 if err := oprot.WriteStructBegin("Endpoint"); err != nil {
162 return fmt.Errorf("%T write struct begin error: %s", p, err)
163 }
164 if err := p.writeField1(oprot); err != nil {
165 return err
166 }
167 if err := p.writeField2(oprot); err != nil {
168 return err
169 }
170 if err := p.writeField3(oprot); err != nil {
171 return err
172 }
173 if err := oprot.WriteFieldStop(); err != nil {
174 return fmt.Errorf("write field stop error: %s", err)
175 }
176 if err := oprot.WriteStructEnd(); err != nil {
177 return fmt.Errorf("write struct stop error: %s", err)
178 }
179 return nil
180 }
181
182 func (p *Endpoint) writeField1(oprot thrift.TProtocol) (err error) {
183 if err := oprot.WriteFieldBegin("ipv4", thrift.I32, 1); err != nil {
184 return fmt.Errorf("%T write field begin error 1:ipv4: %s", p, err)
185 }
186 if err := oprot.WriteI32(int32(p.Ipv4)); err != nil {
187 return fmt.Errorf("%T.ipv4 (1) field write error: %s", p, err)
188 }
189 if err := oprot.WriteFieldEnd(); err != nil {
190 return fmt.Errorf("%T write field end error 1:ipv4: %s", p, err)
191 }
192 return err
193 }
194
195 func (p *Endpoint) writeField2(oprot thrift.TProtocol) (err error) {
196 if err := oprot.WriteFieldBegin("port", thrift.I16, 2); err != nil {
197 return fmt.Errorf("%T write field begin error 2:port: %s", p, err)
198 }
199 if err := oprot.WriteI16(int16(p.Port)); err != nil {
200 return fmt.Errorf("%T.port (2) field write error: %s", p, err)
201 }
202 if err := oprot.WriteFieldEnd(); err != nil {
203 return fmt.Errorf("%T write field end error 2:port: %s", p, err)
204 }
205 return err
206 }
207
208 func (p *Endpoint) writeField3(oprot thrift.TProtocol) (err error) {
209 if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 3); err != nil {
210 return fmt.Errorf("%T write field begin error 3:service_name: %s", p, err)
211 }
212 if err := oprot.WriteString(string(p.ServiceName)); err != nil {
213 return fmt.Errorf("%T.service_name (3) field write error: %s", p, err)
214 }
215 if err := oprot.WriteFieldEnd(); err != nil {
216 return fmt.Errorf("%T write field end error 3:service_name: %s", p, err)
217 }
218 return err
219 }
220
221 func (p *Endpoint) String() string {
222 if p == nil {
223 return "<nil>"
224 }
225 return fmt.Sprintf("Endpoint(%+v)", *p)
226 }
227
228 type Annotation struct {
229 Timestamp int64 `thrift:"timestamp,1" json:"timestamp"`
230 Value string `thrift:"value,2" json:"value"`
231 Host *Endpoint `thrift:"host,3" json:"host"`
232 Duration *int32 `thrift:"duration,4" json:"duration"`
233 }
234
235 func NewAnnotation() *Annotation {
236 return &Annotation{}
237 }
238
239 func (p *Annotation) GetTimestamp() int64 {
240 return p.Timestamp
241 }
242
243 func (p *Annotation) GetValue() string {
244 return p.Value
245 }
246
247 var Annotation_Host_DEFAULT *Endpoint
248
249 func (p *Annotation) GetHost() *Endpoint {
250 if !p.IsSetHost() {
251 return Annotation_Host_DEFAULT
252 }
253 return p.Host
254 }
255
256 var Annotation_Duration_DEFAULT int32
257
258 func (p *Annotation) GetDuration() int32 {
259 if !p.IsSetDuration() {
260 return Annotation_Duration_DEFAULT
261 }
262 return *p.Duration
263 }
264 func (p *Annotation) IsSetHost() bool {
265 return p.Host != nil
266 }
267
268 func (p *Annotation) IsSetDuration() bool {
269 return p.Duration != nil
270 }
271
272 func (p *Annotation) Read(iprot thrift.TProtocol) error {
273 if _, err := iprot.ReadStructBegin(); err != nil {
274 return fmt.Errorf("%T read error: %s", p, err)
275 }
276 for {
277 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
278 if err != nil {
279 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
280 }
281 if fieldTypeId == thrift.STOP {
282 break
283 }
284 switch fieldId {
285 case 1:
286 if err := p.ReadField1(iprot); err != nil {
287 return err
288 }
289 case 2:
290 if err := p.ReadField2(iprot); err != nil {
291 return err
292 }
293 case 3:
294 if err := p.ReadField3(iprot); err != nil {
295 return err
296 }
297 case 4:
298 if err := p.ReadField4(iprot); err != nil {
299 return err
300 }
301 default:
302 if err := iprot.Skip(fieldTypeId); err != nil {
303 return err
304 }
305 }
306 if err := iprot.ReadFieldEnd(); err != nil {
307 return err
308 }
309 }
310 if err := iprot.ReadStructEnd(); err != nil {
311 return fmt.Errorf("%T read struct end error: %s", p, err)
312 }
313 return nil
314 }
315
316 func (p *Annotation) ReadField1(iprot thrift.TProtocol) error {
317 if v, err := iprot.ReadI64(); err != nil {
318 return fmt.Errorf("error reading field 1: %s", err)
319 } else {
320 p.Timestamp = v
321 }
322 return nil
323 }
324
325 func (p *Annotation) ReadField2(iprot thrift.TProtocol) error {
326 if v, err := iprot.ReadString(); err != nil {
327 return fmt.Errorf("error reading field 2: %s", err)
328 } else {
329 p.Value = v
330 }
331 return nil
332 }
333
334 func (p *Annotation) ReadField3(iprot thrift.TProtocol) error {
335 p.Host = &Endpoint{}
336 if err := p.Host.Read(iprot); err != nil {
337 return fmt.Errorf("%T error reading struct: %s", p.Host, err)
338 }
339 return nil
340 }
341
342 func (p *Annotation) ReadField4(iprot thrift.TProtocol) error {
343 if v, err := iprot.ReadI32(); err != nil {
344 return fmt.Errorf("error reading field 4: %s", err)
345 } else {
346 p.Duration = &v
347 }
348 return nil
349 }
350
351 func (p *Annotation) Write(oprot thrift.TProtocol) error {
352 if err := oprot.WriteStructBegin("Annotation"); err != nil {
353 return fmt.Errorf("%T write struct begin error: %s", p, err)
354 }
355 if err := p.writeField1(oprot); err != nil {
356 return err
357 }
358 if err := p.writeField2(oprot); err != nil {
359 return err
360 }
361 if err := p.writeField3(oprot); err != nil {
362 return err
363 }
364 if err := p.writeField4(oprot); err != nil {
365 return err
366 }
367 if err := oprot.WriteFieldStop(); err != nil {
368 return fmt.Errorf("write field stop error: %s", err)
369 }
370 if err := oprot.WriteStructEnd(); err != nil {
371 return fmt.Errorf("write struct stop error: %s", err)
372 }
373 return nil
374 }
375
376 func (p *Annotation) writeField1(oprot thrift.TProtocol) (err error) {
377 if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 1); err != nil {
378 return fmt.Errorf("%T write field begin error 1:timestamp: %s", p, err)
379 }
380 if err := oprot.WriteI64(int64(p.Timestamp)); err != nil {
381 return fmt.Errorf("%T.timestamp (1) field write error: %s", p, err)
382 }
383 if err := oprot.WriteFieldEnd(); err != nil {
384 return fmt.Errorf("%T write field end error 1:timestamp: %s", p, err)
385 }
386 return err
387 }
388
389 func (p *Annotation) writeField2(oprot thrift.TProtocol) (err error) {
390 if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil {
391 return fmt.Errorf("%T write field begin error 2:value: %s", p, err)
392 }
393 if err := oprot.WriteString(string(p.Value)); err != nil {
394 return fmt.Errorf("%T.value (2) field write error: %s", p, err)
395 }
396 if err := oprot.WriteFieldEnd(); err != nil {
397 return fmt.Errorf("%T write field end error 2:value: %s", p, err)
398 }
399 return err
400 }
401
402 func (p *Annotation) writeField3(oprot thrift.TProtocol) (err error) {
403 if p.IsSetHost() {
404 if err := oprot.WriteFieldBegin("host", thrift.STRUCT, 3); err != nil {
405 return fmt.Errorf("%T write field begin error 3:host: %s", p, err)
406 }
407 if err := p.Host.Write(oprot); err != nil {
408 return fmt.Errorf("%T error writing struct: %s", p.Host, err)
409 }
410 if err := oprot.WriteFieldEnd(); err != nil {
411 return fmt.Errorf("%T write field end error 3:host: %s", p, err)
412 }
413 }
414 return err
415 }
416
417 func (p *Annotation) writeField4(oprot thrift.TProtocol) (err error) {
418 if p.IsSetDuration() {
419 if err := oprot.WriteFieldBegin("duration", thrift.I32, 4); err != nil {
420 return fmt.Errorf("%T write field begin error 4:duration: %s", p, err)
421 }
422 if err := oprot.WriteI32(int32(*p.Duration)); err != nil {
423 return fmt.Errorf("%T.duration (4) field write error: %s", p, err)
424 }
425 if err := oprot.WriteFieldEnd(); err != nil {
426 return fmt.Errorf("%T write field end error 4:duration: %s", p, err)
427 }
428 }
429 return err
430 }
431
432 func (p *Annotation) String() string {
433 if p == nil {
434 return "<nil>"
435 }
436 return fmt.Sprintf("Annotation(%+v)", *p)
437 }
438
439 type BinaryAnnotation struct {
440 Key string `thrift:"key,1" json:"key"`
441 Value []byte `thrift:"value,2" json:"value"`
442 AnnotationType AnnotationType `thrift:"annotation_type,3" json:"annotation_type"`
443 Host *Endpoint `thrift:"host,4" json:"host"`
444 }
445
446 func NewBinaryAnnotation() *BinaryAnnotation {
447 return &BinaryAnnotation{}
448 }
449
450 func (p *BinaryAnnotation) GetKey() string {
451 return p.Key
452 }
453
454 func (p *BinaryAnnotation) GetValue() []byte {
455 return p.Value
456 }
457
458 func (p *BinaryAnnotation) GetAnnotationType() AnnotationType {
459 return p.AnnotationType
460 }
461
462 var BinaryAnnotation_Host_DEFAULT *Endpoint
463
464 func (p *BinaryAnnotation) GetHost() *Endpoint {
465 if !p.IsSetHost() {
466 return BinaryAnnotation_Host_DEFAULT
467 }
468 return p.Host
469 }
470 func (p *BinaryAnnotation) IsSetHost() bool {
471 return p.Host != nil
472 }
473
474 func (p *BinaryAnnotation) Read(iprot thrift.TProtocol) error {
475 if _, err := iprot.ReadStructBegin(); err != nil {
476 return fmt.Errorf("%T read error: %s", p, err)
477 }
478 for {
479 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
480 if err != nil {
481 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
482 }
483 if fieldTypeId == thrift.STOP {
484 break
485 }
486 switch fieldId {
487 case 1:
488 if err := p.ReadField1(iprot); err != nil {
489 return err
490 }
491 case 2:
492 if err := p.ReadField2(iprot); err != nil {
493 return err
494 }
495 case 3:
496 if err := p.ReadField3(iprot); err != nil {
497 return err
498 }
499 case 4:
500 if err := p.ReadField4(iprot); err != nil {
501 return err
502 }
503 default:
504 if err := iprot.Skip(fieldTypeId); err != nil {
505 return err
506 }
507 }
508 if err := iprot.ReadFieldEnd(); err != nil {
509 return err
510 }
511 }
512 if err := iprot.ReadStructEnd(); err != nil {
513 return fmt.Errorf("%T read struct end error: %s", p, err)
514 }
515 return nil
516 }
517
518 func (p *BinaryAnnotation) ReadField1(iprot thrift.TProtocol) error {
519 if v, err := iprot.ReadString(); err != nil {
520 return fmt.Errorf("error reading field 1: %s", err)
521 } else {
522 p.Key = v
523 }
524 return nil
525 }
526
527 func (p *BinaryAnnotation) ReadField2(iprot thrift.TProtocol) error {
528 if v, err := iprot.ReadBinary(); err != nil {
529 return fmt.Errorf("error reading field 2: %s", err)
530 } else {
531 p.Value = v
532 }
533 return nil
534 }
535
536 func (p *BinaryAnnotation) ReadField3(iprot thrift.TProtocol) error {
537 if v, err := iprot.ReadI32(); err != nil {
538 return fmt.Errorf("error reading field 3: %s", err)
539 } else {
540 temp := AnnotationType(v)
541 p.AnnotationType = temp
542 }
543 return nil
544 }
545
546 func (p *BinaryAnnotation) ReadField4(iprot thrift.TProtocol) error {
547 p.Host = &Endpoint{}
548 if err := p.Host.Read(iprot); err != nil {
549 return fmt.Errorf("%T error reading struct: %s", p.Host, err)
550 }
551 return nil
552 }
553
554 func (p *BinaryAnnotation) Write(oprot thrift.TProtocol) error {
555 if err := oprot.WriteStructBegin("BinaryAnnotation"); err != nil {
556 return fmt.Errorf("%T write struct begin error: %s", p, err)
557 }
558 if err := p.writeField1(oprot); err != nil {
559 return err
560 }
561 if err := p.writeField2(oprot); err != nil {
562 return err
563 }
564 if err := p.writeField3(oprot); err != nil {
565 return err
566 }
567 if err := p.writeField4(oprot); err != nil {
568 return err
569 }
570 if err := oprot.WriteFieldStop(); err != nil {
571 return fmt.Errorf("write field stop error: %s", err)
572 }
573 if err := oprot.WriteStructEnd(); err != nil {
574 return fmt.Errorf("write struct stop error: %s", err)
575 }
576 return nil
577 }
578
579 func (p *BinaryAnnotation) writeField1(oprot thrift.TProtocol) (err error) {
580 if err := oprot.WriteFieldBegin("key", thrift.STRING, 1); err != nil {
581 return fmt.Errorf("%T write field begin error 1:key: %s", p, err)
582 }
583 if err := oprot.WriteString(string(p.Key)); err != nil {
584 return fmt.Errorf("%T.key (1) field write error: %s", p, err)
585 }
586 if err := oprot.WriteFieldEnd(); err != nil {
587 return fmt.Errorf("%T write field end error 1:key: %s", p, err)
588 }
589 return err
590 }
591
592 func (p *BinaryAnnotation) writeField2(oprot thrift.TProtocol) (err error) {
593 if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil {
594 return fmt.Errorf("%T write field begin error 2:value: %s", p, err)
595 }
596 if err := oprot.WriteBinary(p.Value); err != nil {
597 return fmt.Errorf("%T.value (2) field write error: %s", p, err)
598 }
599 if err := oprot.WriteFieldEnd(); err != nil {
600 return fmt.Errorf("%T write field end error 2:value: %s", p, err)
601 }
602 return err
603 }
604
605 func (p *BinaryAnnotation) writeField3(oprot thrift.TProtocol) (err error) {
606 if err := oprot.WriteFieldBegin("annotation_type", thrift.I32, 3); err != nil {
607 return fmt.Errorf("%T write field begin error 3:annotation_type: %s", p, err)
608 }
609 if err := oprot.WriteI32(int32(p.AnnotationType)); err != nil {
610 return fmt.Errorf("%T.annotation_type (3) field write error: %s", p, err)
611 }
612 if err := oprot.WriteFieldEnd(); err != nil {
613 return fmt.Errorf("%T write field end error 3:annotation_type: %s", p, err)
614 }
615 return err
616 }
617
618 func (p *BinaryAnnotation) writeField4(oprot thrift.TProtocol) (err error) {
619 if p.IsSetHost() {
620 if err := oprot.WriteFieldBegin("host", thrift.STRUCT, 4); err != nil {
621 return fmt.Errorf("%T write field begin error 4:host: %s", p, err)
622 }
623 if err := p.Host.Write(oprot); err != nil {
624 return fmt.Errorf("%T error writing struct: %s", p.Host, err)
625 }
626 if err := oprot.WriteFieldEnd(); err != nil {
627 return fmt.Errorf("%T write field end error 4:host: %s", p, err)
628 }
629 }
630 return err
631 }
632
633 func (p *BinaryAnnotation) String() string {
634 if p == nil {
635 return "<nil>"
636 }
637 return fmt.Sprintf("BinaryAnnotation(%+v)", *p)
638 }
639
640 type Span struct {
641 TraceId int64 `thrift:"trace_id,1" json:"trace_id"`
642 // unused field # 2
643 Name string `thrift:"name,3" json:"name"`
644 Id int64 `thrift:"id,4" json:"id"`
645 ParentId *int64 `thrift:"parent_id,5" json:"parent_id"`
646 Annotations []*Annotation `thrift:"annotations,6" json:"annotations"`
647 // unused field # 7
648 BinaryAnnotations []*BinaryAnnotation `thrift:"binary_annotations,8" json:"binary_annotations"`
649 Debug bool `thrift:"debug,9" json:"debug"`
650 }
651
652 func NewSpan() *Span {
653 return &Span{}
654 }
655
656 func (p *Span) GetTraceId() int64 {
657 return p.TraceId
658 }
659
660 func (p *Span) GetName() string {
661 return p.Name
662 }
663
664 func (p *Span) GetId() int64 {
665 return p.Id
666 }
667
668 var Span_ParentId_DEFAULT int64
669
670 func (p *Span) GetParentId() int64 {
671 if !p.IsSetParentId() {
672 return Span_ParentId_DEFAULT
673 }
674 return *p.ParentId
675 }
676
677 func (p *Span) GetAnnotations() []*Annotation {
678 return p.Annotations
679 }
680
681 func (p *Span) GetBinaryAnnotations() []*BinaryAnnotation {
682 return p.BinaryAnnotations
683 }
684
685 var Span_Debug_DEFAULT bool = false
686
687 func (p *Span) GetDebug() bool {
688 return p.Debug
689 }
690 func (p *Span) IsSetParentId() bool {
691 return p.ParentId != nil
692 }
693
694 func (p *Span) IsSetDebug() bool {
695 return p.Debug != Span_Debug_DEFAULT
696 }
697
698 func (p *Span) Read(iprot thrift.TProtocol) error {
699 if _, err := iprot.ReadStructBegin(); err != nil {
700 return fmt.Errorf("%T read error: %s", p, err)
701 }
702 for {
703 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
704 if err != nil {
705 return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
706 }
707 if fieldTypeId == thrift.STOP {
708 break
709 }
710 switch fieldId {
711 case 1:
712 if err := p.ReadField1(iprot); err != nil {
713 return err
714 }
715 case 3:
716 if err := p.ReadField3(iprot); err != nil {
717 return err
718 }
719 case 4:
720 if err := p.ReadField4(iprot); err != nil {
721 return err
722 }
723 case 5:
724 if err := p.ReadField5(iprot); err != nil {
725 return err
726 }
727 case 6:
728 if err := p.ReadField6(iprot); err != nil {
729 return err
730 }
731 case 8:
732 if err := p.ReadField8(iprot); err != nil {
733 return err
734 }
735 case 9:
736 if err := p.ReadField9(iprot); err != nil {
737 return err
738 }
739 default:
740 if err := iprot.Skip(fieldTypeId); err != nil {
741 return err
742 }
743 }
744 if err := iprot.ReadFieldEnd(); err != nil {
745 return err
746 }
747 }
748 if err := iprot.ReadStructEnd(); err != nil {
749 return fmt.Errorf("%T read struct end error: %s", p, err)
750 }
751 return nil
752 }
753
754 func (p *Span) ReadField1(iprot thrift.TProtocol) error {
755 if v, err := iprot.ReadI64(); err != nil {
756 return fmt.Errorf("error reading field 1: %s", err)
757 } else {
758 p.TraceId = v
759 }
760 return nil
761 }
762
763 func (p *Span) ReadField3(iprot thrift.TProtocol) error {
764 if v, err := iprot.ReadString(); err != nil {
765 return fmt.Errorf("error reading field 3: %s", err)
766 } else {
767 p.Name = v
768 }
769 return nil
770 }
771
772 func (p *Span) ReadField4(iprot thrift.TProtocol) error {
773 if v, err := iprot.ReadI64(); err != nil {
774 return fmt.Errorf("error reading field 4: %s", err)
775 } else {
776 p.Id = v
777 }
778 return nil
779 }
780
781 func (p *Span) ReadField5(iprot thrift.TProtocol) error {
782 if v, err := iprot.ReadI64(); err != nil {
783 return fmt.Errorf("error reading field 5: %s", err)
784 } else {
785 p.ParentId = &v
786 }
787 return nil
788 }
789
790 func (p *Span) ReadField6(iprot thrift.TProtocol) error {
791 _, size, err := iprot.ReadListBegin()
792 if err != nil {
793 return fmt.Errorf("error reading list begin: %s", err)
794 }
795 tSlice := make([]*Annotation, 0, size)
796 p.Annotations = tSlice
797 for i := 0; i < size; i++ {
798 _elem0 := &Annotation{}
799 if err := _elem0.Read(iprot); err != nil {
800 return fmt.Errorf("%T error reading struct: %s", _elem0, err)
801 }
802 p.Annotations = append(p.Annotations, _elem0)
803 }
804 if err := iprot.ReadListEnd(); err != nil {
805 return fmt.Errorf("error reading list end: %s", err)
806 }
807 return nil
808 }
809
810 func (p *Span) ReadField8(iprot thrift.TProtocol) error {
811 _, size, err := iprot.ReadListBegin()
812 if err != nil {
813 return fmt.Errorf("error reading list begin: %s", err)
814 }
815 tSlice := make([]*BinaryAnnotation, 0, size)
816 p.BinaryAnnotations = tSlice
817 for i := 0; i < size; i++ {
818 _elem1 := &BinaryAnnotation{}
819 if err := _elem1.Read(iprot); err != nil {
820 return fmt.Errorf("%T error reading struct: %s", _elem1, err)
821 }
822 p.BinaryAnnotations = append(p.BinaryAnnotations, _elem1)
823 }
824 if err := iprot.ReadListEnd(); err != nil {
825 return fmt.Errorf("error reading list end: %s", err)
826 }
827 return nil
828 }
829
830 func (p *Span) ReadField9(iprot thrift.TProtocol) error {
831 if v, err := iprot.ReadBool(); err != nil {
832 return fmt.Errorf("error reading field 9: %s", err)
833 } else {
834 p.Debug = v
835 }
836 return nil
837 }
838
839 func (p *Span) Write(oprot thrift.TProtocol) error {
840 if err := oprot.WriteStructBegin("Span"); err != nil {
841 return fmt.Errorf("%T write struct begin error: %s", p, err)
842 }
843 if err := p.writeField1(oprot); err != nil {
844 return err
845 }
846 if err := p.writeField3(oprot); err != nil {
847 return err
848 }
849 if err := p.writeField4(oprot); err != nil {
850 return err
851 }
852 if err := p.writeField5(oprot); err != nil {
853 return err
854 }
855 if err := p.writeField6(oprot); err != nil {
856 return err
857 }
858 if err := p.writeField8(oprot); err != nil {
859 return err
860 }
861 if err := p.writeField9(oprot); err != nil {
862 return err
863 }
864 if err := oprot.WriteFieldStop(); err != nil {
865 return fmt.Errorf("write field stop error: %s", err)
866 }
867 if err := oprot.WriteStructEnd(); err != nil {
868 return fmt.Errorf("write struct stop error: %s", err)
869 }
870 return nil
871 }
872
873 func (p *Span) writeField1(oprot thrift.TProtocol) (err error) {
874 if err := oprot.WriteFieldBegin("trace_id", thrift.I64, 1); err != nil {
875 return fmt.Errorf("%T write field begin error 1:trace_id: %s", p, err)
876 }
877 if err := oprot.WriteI64(int64(p.TraceId)); err != nil {
878 return fmt.Errorf("%T.trace_id (1) field write error: %s", p, err)
879 }
880 if err := oprot.WriteFieldEnd(); err != nil {
881 return fmt.Errorf("%T write field end error 1:trace_id: %s", p, err)
882 }
883 return err
884 }
885
886 func (p *Span) writeField3(oprot thrift.TProtocol) (err error) {
887 if err := oprot.WriteFieldBegin("name", thrift.STRING, 3); err != nil {
888 return fmt.Errorf("%T write field begin error 3:name: %s", p, err)
889 }
890 if err := oprot.WriteString(string(p.Name)); err != nil {
891 return fmt.Errorf("%T.name (3) field write error: %s", p, err)
892 }
893 if err := oprot.WriteFieldEnd(); err != nil {
894 return fmt.Errorf("%T write field end error 3:name: %s", p, err)
895 }
896 return err
897 }
898
899 func (p *Span) writeField4(oprot thrift.TProtocol) (err error) {
900 if err := oprot.WriteFieldBegin("id", thrift.I64, 4); err != nil {
901 return fmt.Errorf("%T write field begin error 4:id: %s", p, err)
902 }
903 if err := oprot.WriteI64(int64(p.Id)); err != nil {
904 return fmt.Errorf("%T.id (4) field write error: %s", p, err)
905 }
906 if err := oprot.WriteFieldEnd(); err != nil {
907 return fmt.Errorf("%T write field end error 4:id: %s", p, err)
908 }
909 return err
910 }
911
912 func (p *Span) writeField5(oprot thrift.TProtocol) (err error) {
913 if p.IsSetParentId() {
914 if err := oprot.WriteFieldBegin("parent_id", thrift.I64, 5); err != nil {
915 return fmt.Errorf("%T write field begin error 5:parent_id: %s", p, err)
916 }
917 if err := oprot.WriteI64(int64(*p.ParentId)); err != nil {
918 return fmt.Errorf("%T.parent_id (5) field write error: %s", p, err)
919 }
920 if err := oprot.WriteFieldEnd(); err != nil {
921 return fmt.Errorf("%T write field end error 5:parent_id: %s", p, err)
922 }
923 }
924 return err
925 }
926
927 func (p *Span) writeField6(oprot thrift.TProtocol) (err error) {
928 if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 6); err != nil {
929 return fmt.Errorf("%T write field begin error 6:annotations: %s", p, err)
930 }
931 if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Annotations)); err != nil {
932 return fmt.Errorf("error writing list begin: %s", err)
933 }
934 for _, v := range p.Annotations {
935 if err := v.Write(oprot); err != nil {
936 return fmt.Errorf("%T error writing struct: %s", v, err)
937 }
938 }
939 if err := oprot.WriteListEnd(); err != nil {
940 return fmt.Errorf("error writing list end: %s", err)
941 }
942 if err := oprot.WriteFieldEnd(); err != nil {
943 return fmt.Errorf("%T write field end error 6:annotations: %s", p, err)
944 }
945 return err
946 }
947
948 func (p *Span) writeField8(oprot thrift.TProtocol) (err error) {
949 if err := oprot.WriteFieldBegin("binary_annotations", thrift.LIST, 8); err != nil {
950 return fmt.Errorf("%T write field begin error 8:binary_annotations: %s", p, err)
951 }
952 if err := oprot.WriteListBegin(thrift.STRUCT, len(p.BinaryAnnotations)); err != nil {
953 return fmt.Errorf("error writing list begin: %s", err)
954 }
955 for _, v := range p.BinaryAnnotations {
956 if err := v.Write(oprot); err != nil {
957 return fmt.Errorf("%T error writing struct: %s", v, err)
958 }
959 }
960 if err := oprot.WriteListEnd(); err != nil {
961 return fmt.Errorf("error writing list end: %s", err)
962 }
963 if err := oprot.WriteFieldEnd(); err != nil {
964 return fmt.Errorf("%T write field end error 8:binary_annotations: %s", p, err)
965 }
966 return err
967 }
968
969 func (p *Span) writeField9(oprot thrift.TProtocol) (err error) {
970 if p.IsSetDebug() {
971 if err := oprot.WriteFieldBegin("debug", thrift.BOOL, 9); err != nil {
972 return fmt.Errorf("%T write field begin error 9:debug: %s", p, err)
973 }
974 if err := oprot.WriteBool(bool(p.Debug)); err != nil {
975 return fmt.Errorf("%T.debug (9) field write error: %s", p, err)
976 }
977 if err := oprot.WriteFieldEnd(); err != nil {
978 return fmt.Errorf("%T write field end error 9:debug: %s", p, err)
979 }
980 }
981 return err
982 }
983
984 func (p *Span) String() string {
985 if p == nil {
986 return "<nil>"
987 }
988 return fmt.Sprintf("Span(%+v)", *p)
989 }
+0
-18
tracing/zipkin/_thrift/gen-go/zipkindependencies/constants.go less more
0 // Autogenerated by Thrift Compiler (0.9.2)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package zipkindependencies
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf