diff --git a/addsvc/.gitignore b/addsvc/.gitignore new file mode 100644 index 000000000..87a25340f --- /dev/null +++ b/addsvc/.gitignore @@ -0,0 +1 @@ +addsvc diff --git a/addsvc/_thrift/add.thrift b/addsvc/_thrift/add.thrift new file mode 100644 index 000000000..969c10421 --- /dev/null +++ b/addsvc/_thrift/add.thrift @@ -0,0 +1,7 @@ +struct AddReply { + 1: i64 value +} + +service AddService { + AddReply Add(1: i64 a, 2: i64 b) +} diff --git a/addsvc/_thrift/compile.sh b/addsvc/_thrift/compile.sh new file mode 100755 index 000000000..046192d12 --- /dev/null +++ b/addsvc/_thrift/compile.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# Thrift code generation for Go is broken in the current stable (0.9.2) +# release. See https://issues.apache.org/jira/browse/THRIFT-3021. We prefix +# `thrift` as `_thrift` so the `go` tool ignores the subdir. +# +# See also +# https://thrift.apache.org/tutorial/go + +thrift -r --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift add.thrift diff --git a/addsvc/_thrift/gen-go/add/add_service-remote/add_service-remote.go b/addsvc/_thrift/gen-go/add/add_service-remote/add_service-remote.go new file mode 100755 index 000000000..f350da6b8 --- /dev/null +++ b/addsvc/_thrift/gen-go/add/add_service-remote/add_service-remote.go @@ -0,0 +1,144 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package main + +import ( + "add" + "flag" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "math" + "net" + "net/url" + "os" + "strconv" + "strings" +) + +func Usage() { + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " AddReply Add(i64 a, i64 b)") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +func main() { + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + var parsedUrl url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Parse() + + if len(urlString) > 0 { + parsedUrl, err := url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransport(trans) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + client := add.NewAddServiceClientFactory(trans, protocolFactory) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "Add": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "Add requires 2 args") + flag.Usage() + } + argvalue0, err4 := (strconv.ParseInt(flag.Arg(1), 10, 64)) + if err4 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1, err5 := (strconv.ParseInt(flag.Arg(2), 10, 64)) + if err5 != nil { + Usage() + return + } + value1 := argvalue1 + fmt.Print(client.Add(value0, value1)) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } +} diff --git a/addsvc/_thrift/gen-go/add/addservice.go b/addsvc/_thrift/gen-go/add/addservice.go new file mode 100644 index 000000000..8ab56a506 --- /dev/null +++ b/addsvc/_thrift/gen-go/add/addservice.go @@ -0,0 +1,433 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package add + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +type AddService interface { + // Parameters: + // - A + // - B + Add(a int64, b int64) (r *AddReply, err error) +} + +type AddServiceClient struct { + Transport thrift.TTransport + ProtocolFactory thrift.TProtocolFactory + InputProtocol thrift.TProtocol + OutputProtocol thrift.TProtocol + SeqId int32 +} + +func NewAddServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AddServiceClient { + return &AddServiceClient{Transport: t, + ProtocolFactory: f, + InputProtocol: f.GetProtocol(t), + OutputProtocol: f.GetProtocol(t), + SeqId: 0, + } +} + +func NewAddServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AddServiceClient { + return &AddServiceClient{Transport: t, + ProtocolFactory: nil, + InputProtocol: iprot, + OutputProtocol: oprot, + SeqId: 0, + } +} + +// Parameters: +// - A +// - B +func (p *AddServiceClient) Add(a int64, b int64) (r *AddReply, err error) { + if err = p.sendAdd(a, b); err != nil { + return + } + return p.recvAdd() +} + +func (p *AddServiceClient) sendAdd(a int64, b int64) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("Add", thrift.CALL, p.SeqId); err != nil { + return + } + args := AddArgs{ + A: a, + B: b, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *AddServiceClient) recvAdd() (value *AddReply, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error1 error + error1, err = error0.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error1 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Add failed: out of sequence response") + return + } + result := AddResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + value = result.GetSuccess() + return +} + +type AddServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler AddService +} + +func (p *AddServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *AddServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *AddServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewAddServiceProcessor(handler AddService) *AddServiceProcessor { + + self2 := &AddServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self2.processorMap["Add"] = &addServiceProcessorAdd{handler: handler} + return self2 +} + +func (p *AddServiceProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x3.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, x3 + +} + +type addServiceProcessorAdd struct { + handler AddService +} + +func (p *addServiceProcessorAdd) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AddArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Add", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := AddResult{} + var retval *AddReply + var err2 error + if retval, err2 = p.handler.Add(args.A, args.B); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Add: "+err2.Error()) + oprot.WriteMessageBegin("Add", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Add", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +// HELPER FUNCTIONS AND STRUCTURES + +type AddArgs struct { + A int64 `thrift:"a,1" json:"a"` + B int64 `thrift:"b,2" json:"b"` +} + +func NewAddArgs() *AddArgs { + return &AddArgs{} +} + +func (p *AddArgs) GetA() int64 { + return p.A +} + +func (p *AddArgs) GetB() int64 { + return p.B +} +func (p *AddArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *AddArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.A = v + } + return nil +} + +func (p *AddArgs) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.B = v + } + return nil +} + +func (p *AddArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Add_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *AddArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("a", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:a: %s", p, err) + } + if err := oprot.WriteI64(int64(p.A)); err != nil { + return fmt.Errorf("%T.a (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:a: %s", p, err) + } + return err +} + +func (p *AddArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("b", thrift.I64, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:b: %s", p, err) + } + if err := oprot.WriteI64(int64(p.B)); err != nil { + return fmt.Errorf("%T.b (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:b: %s", p, err) + } + return err +} + +func (p *AddArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AddArgs(%+v)", *p) +} + +type AddResult struct { + Success *AddReply `thrift:"success,0" json:"success"` +} + +func NewAddResult() *AddResult { + return &AddResult{} +} + +var AddResult_Success_DEFAULT *AddReply + +func (p *AddResult) GetSuccess() *AddReply { + if !p.IsSetSuccess() { + return AddResult_Success_DEFAULT + } + return p.Success +} +func (p *AddResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AddResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *AddResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = &AddReply{} + if err := p.Success.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Success, err) + } + return nil +} + +func (p *AddResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Add_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *AddResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := p.Success.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Success, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *AddResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AddResult(%+v)", *p) +} diff --git a/addsvc/_thrift/gen-go/add/constants.go b/addsvc/_thrift/gen-go/add/constants.go new file mode 100644 index 000000000..0b745ba54 --- /dev/null +++ b/addsvc/_thrift/gen-go/add/constants.go @@ -0,0 +1,18 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package add + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +func init() { +} diff --git a/addsvc/_thrift/gen-go/add/ttypes.go b/addsvc/_thrift/gen-go/add/ttypes.go new file mode 100644 index 000000000..23adcef87 --- /dev/null +++ b/addsvc/_thrift/gen-go/add/ttypes.go @@ -0,0 +1,105 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package add + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var GoUnusedProtection__ int + +type AddReply struct { + Value int64 `thrift:"value,1" json:"value"` +} + +func NewAddReply() *AddReply { + return &AddReply{} +} + +func (p *AddReply) GetValue() int64 { + return p.Value +} +func (p *AddReply) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *AddReply) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Value = v + } + return nil +} + +func (p *AddReply) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("AddReply"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *AddReply) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("value", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:value: %s", p, err) + } + if err := oprot.WriteI64(int64(p.Value)); err != nil { + return fmt.Errorf("%T.value (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:value: %s", p, err) + } + return err +} + +func (p *AddReply) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AddReply(%+v)", *p) +} diff --git a/addsvc/add.go b/addsvc/add.go new file mode 100644 index 000000000..12c037b9a --- /dev/null +++ b/addsvc/add.go @@ -0,0 +1,23 @@ +package main + +// Add is the abstract definition of what this service does. It could easily +// be an interface type with multiple methods. Each method would be an +// endpoint. +type Add func(int64, int64) int64 + +func pureAdd(a, b int64) int64 { return a + b } + +func addVia(r Resource) Add { + return func(a, b int64) int64 { + return r.Value(a) + r.Value(b) + } +} + +// Resource represents some dependency, outside of our control. +type Resource interface { + Value(int64) int64 +} + +type mockResource struct{} + +func (mockResource) Value(i int64) int64 { return i } diff --git a/addsvc/endpoint.go b/addsvc/endpoint.go new file mode 100644 index 000000000..444f42f09 --- /dev/null +++ b/addsvc/endpoint.go @@ -0,0 +1,32 @@ +package main + +import ( + "github.com/peterbourgon/gokit/server" + "golang.org/x/net/context" +) + +// makeEndpoint returns a server.Endpoint wrapping the passed Add. If Add were +// an interface with multiple methods, we'd need individual endpoints for +// each. +// +// This function is just boiler-plate; in theory, it could be generated. +func makeEndpoint(a Add) server.Endpoint { + return func(ctx context.Context, req server.Request) (server.Response, error) { + select { + case <-ctx.Done(): + return nil, server.ErrContextCanceled + default: + } + + addReq, ok := req.(*request) + if !ok { + return nil, server.ErrBadCast + } + + v := a(addReq.A, addReq.B) + + return response{ + V: v, + }, nil + } +} diff --git a/addsvc/enhancements.go b/addsvc/enhancements.go new file mode 100644 index 000000000..238a3bac6 --- /dev/null +++ b/addsvc/enhancements.go @@ -0,0 +1,17 @@ +package main + +import ( + "time" + + "github.com/peterbourgon/gokit/log" +) + +func logging(logger log.Logger, add Add) Add { + return func(a, b int64) (v int64) { + defer func(begin time.Time) { + logger.Log("a", a, "b", b, "result", v, "took", time.Since(begin)) + }(time.Now()) + v = add(a, b) + return + } +} diff --git a/addsvc/grpc_binding.go b/addsvc/grpc_binding.go new file mode 100644 index 000000000..027a00c8f --- /dev/null +++ b/addsvc/grpc_binding.go @@ -0,0 +1,55 @@ +package main + +import ( + "time" + + "golang.org/x/net/context" + + "github.com/peterbourgon/gokit/addsvc/pb" + "github.com/peterbourgon/gokit/metrics" + "github.com/peterbourgon/gokit/server" +) + +// A binding wraps an Endpoint so that it's usable by a transport. grpcBinding +// makes an Endpoint usable over gRPC. +type grpcBinding struct{ server.Endpoint } + +// Add implements the proto3 AddServer by forwarding to the wrapped Endpoint. +// +// As far as I can tell, gRPC doesn't (currently) provide a user-accessible +// way to manipulate the RPC context, like headers for HTTP. So we don't have +// a way to transport e.g. Zipkin IDs with the request. TODO. +func (b grpcBinding) Add(ctx context.Context, req *pb.AddRequest) (*pb.AddReply, error) { + addReq := request{req.A, req.B} + r, err := b.Endpoint(ctx, addReq) + if err != nil { + return nil, err + } + + resp, ok := r.(*response) + if !ok { + return nil, server.ErrBadCast + } + + return &pb.AddReply{ + V: resp.V, + }, nil +} + +func grpcInstrument(requests metrics.Counter, duration metrics.Histogram) func(pb.AddServer) pb.AddServer { + return func(next pb.AddServer) pb.AddServer { + return grpcInstrumented{requests, duration, next} + } +} + +type grpcInstrumented struct { + requests metrics.Counter + duration metrics.Histogram + next pb.AddServer +} + +func (i grpcInstrumented) Add(ctx context.Context, req *pb.AddRequest) (*pb.AddReply, error) { + i.requests.Add(1) + defer func(begin time.Time) { i.duration.Observe(time.Since(begin).Nanoseconds()) }(time.Now()) + return i.next.Add(ctx, req) +} diff --git a/addsvc/http_binding.go b/addsvc/http_binding.go new file mode 100644 index 000000000..0d5dff3a6 --- /dev/null +++ b/addsvc/http_binding.go @@ -0,0 +1,44 @@ +package main + +import ( + "encoding/json" + "io" + "net/http" + "time" + + "golang.org/x/net/context" + + "github.com/peterbourgon/gokit/metrics" + "github.com/peterbourgon/gokit/server" +) + +// jsonCodec implements transport/codec, decoding and encoding requests and +// responses respectively as JSON. It requires that the concrete request and +// response types support JSON de/serialization. +// +// This type is mostly boiler-plate; in theory, it could be generated. +type jsonCodec struct{} + +func (jsonCodec) Decode(ctx context.Context, r io.Reader) (server.Request, context.Context, error) { + var req request + err := json.NewDecoder(r).Decode(&req) + return &req, ctx, err +} + +func (jsonCodec) Encode(w io.Writer, resp server.Response) error { + return json.NewEncoder(w).Encode(resp) +} + +// The HTTP binding exists in the HTTP transport package, because it uses the +// codec to deserialize and serialize requests and responses, and therefore +// doesn't need to have access to the concrete request and response types. + +func httpInstrument(requests metrics.Counter, duration metrics.Histogram) func(http.Handler) http.Handler { + return func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + requests.Add(1) + defer func(begin time.Time) { duration.Observe(time.Since(begin).Nanoseconds()) }(time.Now()) + next.ServeHTTP(w, r) + }) + } +} diff --git a/addsvc/main.go b/addsvc/main.go new file mode 100644 index 000000000..19235f27d --- /dev/null +++ b/addsvc/main.go @@ -0,0 +1,185 @@ +package main + +import ( + "flag" + "fmt" + "io/ioutil" + stdlog "log" + "net" + "net/http" + "os" + "os/signal" + "syscall" + "time" + + "github.com/apache/thrift/lib/go/thrift" + "github.com/streadway/handy/cors" + "github.com/streadway/handy/encoding" + "golang.org/x/net/context" + "google.golang.org/grpc" + + thriftadd "github.com/peterbourgon/gokit/addsvc/_thrift/gen-go/add" + "github.com/peterbourgon/gokit/addsvc/pb" + kitlog "github.com/peterbourgon/gokit/log" + "github.com/peterbourgon/gokit/metrics" + "github.com/peterbourgon/gokit/metrics/expvar" + "github.com/peterbourgon/gokit/metrics/statsd" + "github.com/peterbourgon/gokit/server" + "github.com/peterbourgon/gokit/tracing/zipkin" + kithttp "github.com/peterbourgon/gokit/transport/http" +) + +func main() { + var ( + httpAddr = flag.String("http.addr", ":8001", "Address for HTTP (JSON) server") + grpcAddr = flag.String("grpc.addr", ":8002", "Address for gRPC server") + thriftAddr = flag.String("thrift.addr", ":8003", "Address for Thrift server") + thriftProtocol = flag.String("thrift.protocol", "binary", "binary, compact, json, simplejson") + thriftBufferSize = flag.Int("thrift.buffer.size", 0, "0 for unbuffered") + thriftFramed = flag.Bool("thrift.framed", false, "true to enable framing") + ) + flag.Parse() + + // `package metrics` domain + requests := metrics.NewMultiCounter( + expvar.NewCounter("requests"), + statsd.NewCounter(ioutil.Discard, "requests", time.Second), + ) + duration := metrics.NewMultiHistogram( + expvar.NewHistogram("duration_ns", 0, 100000000, 3), + statsd.NewHistogram(ioutil.Discard, "duration_ns", time.Second), + ) + + // `package tracing` domain + zipkinHost := "some-host" // TODO + zipkinCollector := zipkin.NopCollector{} // TODO + zipkinAddName := "ADD" // is that right? + zipkinAddSpanFunc := zipkin.NewSpanFunc(zipkinHost, zipkinAddName) + + // `package log` domain + var logger kitlog.Logger + logger = kitlog.NewPrefixLogger(kitlog.StdlibWriter{}) + logger = kitlog.With(logger, "ts", kitlog.DefaultTimestampUTC) + kitlog.DefaultLogger = logger // for other gokit components + stdlog.SetOutput(os.Stderr) // + stdlog.SetFlags(0) // flags are handled in our logger + + // Our business and operational domain + var a Add + a = pureAdd + a = logging(logger, a) + + // `package server` domain + var e server.Endpoint + e = makeEndpoint(a) + e = zipkin.AnnotateEndpoint(zipkinAddSpanFunc, zipkinCollector)(e) + // e = someother.Middleware(arg1, arg2)(e) + + // Mechanical stuff + root := context.Background() + errc := make(chan error) + + go func() { + errc <- interrupt() + }() + + // Transport: gRPC + go func() { + ln, err := net.Listen("tcp", *grpcAddr) + if err != nil { + errc <- err + return + } + s := grpc.NewServer() // uses its own context? + field := metrics.Field{Key: "transport", Value: "grpc"} + + var addServer pb.AddServer + addServer = grpcBinding{e} + addServer = grpcInstrument(requests.With(field), duration.With(field))(addServer) + + pb.RegisterAddServer(s, addServer) + logger.Log("msg", "gRPC server started", "addr", *grpcAddr) + errc <- s.Serve(ln) + }() + + // Transport: HTTP (JSON) + go func() { + ctx, cancel := context.WithCancel(root) + defer cancel() + + field := metrics.Field{Key: "transport", Value: "http"} + before := kithttp.Before(zipkin.ToContext(zipkin.FromHTTP(zipkinAddSpanFunc))) + after := kithttp.After(kithttp.SetContentType("application/json")) + + var handler http.Handler + handler = kithttp.NewBinding(ctx, jsonCodec{}, e, before, after) + handler = encoding.Gzip(handler) + handler = cors.Middleware(cors.Config{})(handler) + handler = httpInstrument(requests.With(field), duration.With(field))(handler) + + mux := http.NewServeMux() + mux.Handle("/add", handler) + logger.Log("msg", "HTTP server started", "addr", *httpAddr) + errc <- http.ListenAndServe(*httpAddr, mux) + }() + + // Transport: Thrift + go func() { + ctx, cancel := context.WithCancel(root) + defer cancel() + + var protocolFactory thrift.TProtocolFactory + switch *thriftProtocol { + case "binary": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + default: + errc <- fmt.Errorf("invalid Thrift protocol %q", *thriftProtocol) + return + } + + var transportFactory thrift.TTransportFactory + if *thriftBufferSize > 0 { + transportFactory = thrift.NewTBufferedTransportFactory(*thriftBufferSize) + } else { + transportFactory = thrift.NewTTransportFactory() + } + + if *thriftFramed { + transportFactory = thrift.NewTFramedTransportFactory(transportFactory) + } + + transport, err := thrift.NewTServerSocket(*thriftAddr) + if err != nil { + errc <- err + return + } + + field := metrics.Field{Key: "transport", Value: "thrift"} + + var service thriftadd.AddService + service = thriftBinding{ctx, e} + service = thriftInstrument(requests.With(field), duration.With(field))(service) + + logger.Log("msg", "Thrift server started", "addr", *thriftAddr) + errc <- thrift.NewTSimpleServer4( + thriftadd.NewAddServiceProcessor(service), + transport, + transportFactory, + protocolFactory, + ).Serve() + }() + + logger.Log("fatal", <-errc) +} + +func interrupt() error { + c := make(chan os.Signal) + signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) + return fmt.Errorf("%s", <-c) +} diff --git a/addsvc/pb/add.pb.go b/addsvc/pb/add.pb.go new file mode 100644 index 000000000..fbe7f5bd1 --- /dev/null +++ b/addsvc/pb/add.pb.go @@ -0,0 +1,110 @@ +// Code generated by protoc-gen-go. +// source: add.proto +// DO NOT EDIT! + +/* +Package pb is a generated protocol buffer package. + +It is generated from these files: + add.proto + +It has these top-level messages: + AddRequest + AddReply +*/ +package pb + +import proto "github.com/golang/protobuf/proto" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal + +// The request contains two parameters. +type AddRequest struct { + A int64 `protobuf:"varint,1,opt,name=a" json:"a,omitempty"` + B int64 `protobuf:"varint,2,opt,name=b" json:"b,omitempty"` +} + +func (m *AddRequest) Reset() { *m = AddRequest{} } +func (m *AddRequest) String() string { return proto.CompactTextString(m) } +func (*AddRequest) ProtoMessage() {} + +// The response contains the result of the calculation. +type AddReply struct { + V int64 `protobuf:"varint,1,opt,name=v" json:"v,omitempty"` +} + +func (m *AddReply) Reset() { *m = AddReply{} } +func (m *AddReply) String() string { return proto.CompactTextString(m) } +func (*AddReply) ProtoMessage() {} + +func init() { +} + +// Client API for Add service + +type AddClient interface { + // Adds two integers. + Add(ctx context.Context, in *AddRequest, opts ...grpc.CallOption) (*AddReply, error) +} + +type addClient struct { + cc *grpc.ClientConn +} + +func NewAddClient(cc *grpc.ClientConn) AddClient { + return &addClient{cc} +} + +func (c *addClient) Add(ctx context.Context, in *AddRequest, opts ...grpc.CallOption) (*AddReply, error) { + out := new(AddReply) + err := grpc.Invoke(ctx, "/pb.Add/Add", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for Add service + +type AddServer interface { + // Adds two integers. + Add(context.Context, *AddRequest) (*AddReply, error) +} + +func RegisterAddServer(s *grpc.Server, srv AddServer) { + s.RegisterService(&_Add_serviceDesc, srv) +} + +func _Add_Add_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(AddRequest) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(AddServer).Add(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +var _Add_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.Add", + HandlerType: (*AddServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Add", + Handler: _Add_Add_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, +} diff --git a/addsvc/pb/add.proto b/addsvc/pb/add.proto new file mode 100644 index 000000000..eca5f20e0 --- /dev/null +++ b/addsvc/pb/add.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package pb; + +// The Add service definition. +service Add { + // Adds two integers. + rpc Add (AddRequest) returns (AddReply) {} +} + +// The request contains two parameters. +message AddRequest { + int64 a = 1; + int64 b = 2; +} + +// The response contains the result of the calculation. +message AddReply { + int64 v = 1; +} diff --git a/addsvc/pb/compile.sh b/addsvc/pb/compile.sh new file mode 100755 index 000000000..090afc08a --- /dev/null +++ b/addsvc/pb/compile.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +# Update protoc via +# go get -u github.com/golang/protobuf/{proto,protoc-gen-go} +# +# See also +# https://github.com/grpc/grpc-common/tree/master/go + +protoc add.proto --go_out=plugins=grpc:. diff --git a/addsvc/request_response.go b/addsvc/request_response.go new file mode 100644 index 000000000..77936934f --- /dev/null +++ b/addsvc/request_response.go @@ -0,0 +1,13 @@ +package main + +// The request and response types should be annotated sufficiently for all +// transports we intend to use. + +type request struct { + A int64 `json:"a"` + B int64 `json:"b"` +} + +type response struct { + V int64 `json:"v"` +} diff --git a/addsvc/thrift_binding.go b/addsvc/thrift_binding.go new file mode 100644 index 000000000..e62165287 --- /dev/null +++ b/addsvc/thrift_binding.go @@ -0,0 +1,51 @@ +package main + +import ( + "time" + + "golang.org/x/net/context" + + thriftadd "github.com/peterbourgon/gokit/addsvc/_thrift/gen-go/add" + "github.com/peterbourgon/gokit/metrics" + "github.com/peterbourgon/gokit/server" +) + +// A binding wraps an Endpoint so that it's usable by a transport. +// thriftBinding makes an Endpoint usable over Thrift. +type thriftBinding struct { + context.Context + server.Endpoint +} + +// Add implements Thrift's AddService interface. +func (tb thriftBinding) Add(a, b int64) (*thriftadd.AddReply, error) { + r, err := tb.Endpoint(tb.Context, request{a, b}) + if err != nil { + return nil, err + } + + resp, ok := r.(*response) + if !ok { + return nil, server.ErrBadCast + } + + return &thriftadd.AddReply{Value: resp.V}, nil +} + +func thriftInstrument(requests metrics.Counter, duration metrics.Histogram) func(thriftadd.AddService) thriftadd.AddService { + return func(next thriftadd.AddService) thriftadd.AddService { + return thriftInstrumented{requests, duration, next} + } +} + +type thriftInstrumented struct { + requests metrics.Counter + duration metrics.Histogram + next thriftadd.AddService +} + +func (i thriftInstrumented) Add(a, b int64) (*thriftadd.AddReply, error) { + i.requests.Add(1) + defer func(begin time.Time) { i.duration.Observe(time.Since(begin).Nanoseconds()) }(time.Now()) + return i.next.Add(a, b) +} diff --git a/log/default_logger.go b/log/default_logger.go new file mode 100644 index 000000000..5a70efc2f --- /dev/null +++ b/log/default_logger.go @@ -0,0 +1,5 @@ +package log + +// DefaultLogger is used by gokit components. By default, it's a PrefixLogger +// that writes to the stdlib log. +var DefaultLogger = NewPrefixLogger(StdlibWriter{}) diff --git a/log/prefix_logger.go b/log/prefix_logger.go index f37324a72..8fbfa5fd1 100644 --- a/log/prefix_logger.go +++ b/log/prefix_logger.go @@ -1,6 +1,7 @@ package log import ( + "bytes" "fmt" "io" ) @@ -19,17 +20,18 @@ func (l prefixLogger) Log(keyvals ...interface{}) error { if len(keyvals)%2 == 1 { panic("odd number of keyvals") } + buf := &bytes.Buffer{} for i := 0; i < len(keyvals); i += 2 { if i != 0 { - if _, err := fmt.Fprint(l.Writer, " "); err != nil { + if _, err := fmt.Fprint(buf, " "); err != nil { return err } } - if _, err := fmt.Fprintf(l.Writer, "%s=%v", keyvals[i], keyvals[i+1]); err != nil { + if _, err := fmt.Fprintf(buf, "%s=%v", keyvals[i], keyvals[i+1]); err != nil { return err } } - if _, err := fmt.Fprintln(l.Writer); err != nil { + if _, err := fmt.Fprintln(l.Writer, buf.String()); err != nil { return err } return nil diff --git a/log/stdlib_writer.go b/log/stdlib.go similarity index 56% rename from log/stdlib_writer.go rename to log/stdlib.go index fcdea1eee..4869f8de7 100644 --- a/log/stdlib_writer.go +++ b/log/stdlib.go @@ -2,53 +2,66 @@ package log import ( "io" + "log" "regexp" + "strings" ) -// StdlibWriter wraps a Logger and allows it to be passed to the stdlib +// StdlibWriter implements io.Writer by invoking the stdlib log.Printf. It's +// designed to be passed to a gokit logger as the writer, for cases where it's +// desirable to pipe all log output to the same, canonical destination. +type StdlibWriter struct{} + +// Write implements io.Writer. +func (w StdlibWriter) Write(p []byte) (int, error) { + log.Printf(strings.TrimSpace(string(p))) + return len(p), nil +} + +// StdlibAdapter wraps a Logger and allows it to be passed to the stdlib // logger's SetOutput. It will extract date/timestamps, filenames, and // messages, and place them under relevant keys. -type StdlibWriter struct { +type StdlibAdapter struct { Logger timestampKey string fileKey string messageKey string } -// StdlibWriterOption sets a parameter for the StdlibWriter. -type StdlibWriterOption func(*StdlibWriter) +// StdlibAdapterOption sets a parameter for the StdlibAdapter. +type StdlibAdapterOption func(*StdlibAdapter) // TimestampKey sets the key for the timestamp field. By default, it's "ts". -func TimestampKey(key string) StdlibWriterOption { - return func(w *StdlibWriter) { w.timestampKey = key } +func TimestampKey(key string) StdlibAdapterOption { + return func(a *StdlibAdapter) { a.timestampKey = key } } // FileKey sets the key for the file and line field. By default, it's "file". -func FileKey(key string) StdlibWriterOption { - return func(w *StdlibWriter) { w.fileKey = key } +func FileKey(key string) StdlibAdapterOption { + return func(a *StdlibAdapter) { a.fileKey = key } } // MessageKey sets the key for the actual log message. By default, it's "msg". -func MessageKey(key string) StdlibWriterOption { - return func(w *StdlibWriter) { w.messageKey = key } +func MessageKey(key string) StdlibAdapterOption { + return func(a *StdlibAdapter) { a.messageKey = key } } -// NewStdlibWriter returns a new StdlibWriter wrapper around the passed +// NewStdlibAdapter returns a new StdlibAdapter wrapper around the passed // logger. It's designed to be passed to log.SetOutput. -func NewStdlibWriter(logger Logger, options ...StdlibWriterOption) io.Writer { - w := StdlibWriter{ +func NewStdlibAdapter(logger Logger, options ...StdlibAdapterOption) io.Writer { + a := StdlibAdapter{ Logger: logger, timestampKey: "ts", fileKey: "file", messageKey: "msg", } for _, option := range options { - option(&w) + option(&a) } - return w + return a } -func (w StdlibWriter) Write(p []byte) (int, error) { +func (a StdlibAdapter) Write(p []byte) (int, error) { result := subexps(p) keyvals := []interface{}{} var timestamp string @@ -62,15 +75,15 @@ func (w StdlibWriter) Write(p []byte) (int, error) { timestamp += time } if timestamp != "" { - keyvals = append(keyvals, w.timestampKey, timestamp) + keyvals = append(keyvals, a.timestampKey, timestamp) } if file, ok := result["file"]; ok && file != "" { - keyvals = append(keyvals, w.fileKey, file) + keyvals = append(keyvals, a.fileKey, file) } if msg, ok := result["msg"]; ok { - keyvals = append(keyvals, w.messageKey, msg) + keyvals = append(keyvals, a.messageKey, msg) } - if err := w.Logger.Log(keyvals...); err != nil { + if err := a.Logger.Log(keyvals...); err != nil { return 0, err } return len(p), nil diff --git a/log/stdlib_writer_test.go b/log/stdlib_test.go similarity index 84% rename from log/stdlib_writer_test.go rename to log/stdlib_test.go index e972206a8..9df922d42 100644 --- a/log/stdlib_writer_test.go +++ b/log/stdlib_test.go @@ -8,10 +8,21 @@ import ( "time" ) -func TestStdlibWriterUsage(t *testing.T) { +func TestStdlibWriter(t *testing.T) { + buf := &bytes.Buffer{} + log.SetOutput(buf) + logger := NewPrefixLogger(StdlibWriter{}) + logger.Log("key", "val") + timestamp := time.Now().Format("2006/01/02 15:04:05") + if want, have := timestamp+" key=val\n", buf.String(); want != have { + t.Errorf("want %q, have %q", want, have) + } +} + +func TestStdlibAdapterUsage(t *testing.T) { buf := &bytes.Buffer{} logger := NewPrefixLogger(buf) - writer := NewStdlibWriter(logger) + writer := NewStdlibAdapter(logger) log.SetOutput(writer) now := time.Now() @@ -23,9 +34,9 @@ func TestStdlibWriterUsage(t *testing.T) { log.Ldate: "ts=" + date + " msg=hello\n", log.Ltime: "ts=" + time + " msg=hello\n", log.Ldate | log.Ltime: "ts=" + date + " " + time + " msg=hello\n", - log.Lshortfile: "file=stdlib_writer_test.go:32 msg=hello\n", - log.Lshortfile | log.Ldate: "ts=" + date + " file=stdlib_writer_test.go:32 msg=hello\n", - log.Lshortfile | log.Ldate | log.Ltime: "ts=" + date + " " + time + " file=stdlib_writer_test.go:32 msg=hello\n", + log.Lshortfile: "file=stdlib_test.go:43 msg=hello\n", + log.Lshortfile | log.Ldate: "ts=" + date + " file=stdlib_test.go:43 msg=hello\n", + log.Lshortfile | log.Ldate | log.Ltime: "ts=" + date + " " + time + " file=stdlib_test.go:43 msg=hello\n", } { buf.Reset() log.SetFlags(flag) @@ -36,10 +47,10 @@ func TestStdlibWriterUsage(t *testing.T) { } } -func TestStdLibWriterExtraction(t *testing.T) { +func TestStdLibAdapterExtraction(t *testing.T) { buf := &bytes.Buffer{} logger := NewPrefixLogger(buf) - writer := NewStdlibWriter(logger) + writer := NewStdlibAdapter(logger) for input, want := range map[string]string{ "hello": "msg=hello\n", "2009/01/23: hello": "ts=2009/01/23 msg=hello\n", @@ -60,7 +71,7 @@ func TestStdLibWriterExtraction(t *testing.T) { } } -func TestStdlibWriterSubexps(t *testing.T) { +func TestStdlibAdapterSubexps(t *testing.T) { for input, wantMap := range map[string]map[string]string{ "hello world": map[string]string{ "date": "", diff --git a/log/value.go b/log/value.go index 3ae74f097..a9881ceb3 100644 --- a/log/value.go +++ b/log/value.go @@ -40,16 +40,13 @@ func Timestamp(t func() time.Time) Valuer { } var ( - // DefaultTimestamp is a Timestamp Valuer that returns the current - // wallclock time, respecting time zones, when bound. - DefaultTimestamp = Timestamp(time.Now) + // DefaultTimestamp is a Valuer that returns the current wallclock time, + // respecting time zones, when bound. + DefaultTimestamp Valuer = func() interface{} { return time.Now().Format(time.RFC3339) } - // DefaultTimestampUTC wraps DefaultTimestamp but ensures the returned - // time is always in UTC. Note that it invokes DefaultTimestamp, and so - // reflects any changes to the DefaultTimestamp package global. - DefaultTimestampUTC = Timestamp(func() time.Time { - return DefaultTimestamp().(time.Time).UTC() - }) + // DefaultTimestampUTC is a Valuer that returns the current time in UTC + // when bound. + DefaultTimestampUTC Valuer = func() interface{} { return time.Now().UTC().Format(time.RFC3339) } ) // Caller returns a Valuer that returns a file and line from a specified depth @@ -60,6 +57,6 @@ func Caller(depth int) Valuer { var ( // DefaultCaller is a Valuer that returns the file and line where the Log - // method was invoked. + // method was invoked. It can only be used with log.With. DefaultCaller = Caller(3) ) diff --git a/log/value_test.go b/log/value_test.go index b8797207a..3a7360de4 100644 --- a/log/value_test.go +++ b/log/value_test.go @@ -34,7 +34,7 @@ func TestValueBinding(t *testing.T) { t.Errorf("output[1]: want %v, have %v", want, have) } if want, have := "value_test.go:28", fmt.Sprint(output[3]); want != have { - t.Fatalf("output[3]: want %s, have %s", want, have) + t.Errorf("output[3]: want %s, have %s", want, have) } // A second attempt to confirm the bindings are truly dynamic. @@ -47,7 +47,7 @@ func TestValueBinding(t *testing.T) { t.Errorf("output[1]: want %v, have %v", want, have) } if want, have := "value_test.go:41", fmt.Sprint(output[3]); want != have { - t.Fatalf("output[3]: want %s, have %s", want, have) + t.Errorf("output[3]: want %s, have %s", want, have) } } diff --git a/metrics/time_histogram.go b/metrics/time_histogram.go index 0a8de89ea..a8fc54c37 100644 --- a/metrics/time_histogram.go +++ b/metrics/time_histogram.go @@ -9,16 +9,16 @@ type TimeHistogram interface { } type timeHistogram struct { - Histogram unit time.Duration + Histogram } // NewTimeHistogram returns a TimeHistogram wrapper around the passed // Histogram, in units of unit. -func NewTimeHistogram(h Histogram, unit time.Duration) TimeHistogram { +func NewTimeHistogram(unit time.Duration, h Histogram) TimeHistogram { return &timeHistogram{ - Histogram: h, unit: unit, + Histogram: h, } } diff --git a/metrics/time_histogram_test.go b/metrics/time_histogram_test.go index 6ca7d347a..a704d9933 100644 --- a/metrics/time_histogram_test.go +++ b/metrics/time_histogram_test.go @@ -13,7 +13,7 @@ func TestTimeHistogram(t *testing.T) { const metricName string = "test_time_histogram" quantiles := []int{50, 90, 99} h0 := expvar.NewHistogram(metricName, 0, 200, 3, quantiles...) - h := metrics.NewTimeHistogram(h0, time.Millisecond) + h := metrics.NewTimeHistogram(time.Millisecond, h0) const seed, mean, stdev int64 = 321, 100, 20 for i := 0; i < 4321; i++ { diff --git a/server/server.go b/server/server.go new file mode 100644 index 000000000..a1542027d --- /dev/null +++ b/server/server.go @@ -0,0 +1,24 @@ +package server + +import ( + "errors" + + "golang.org/x/net/context" +) + +// Request is an RPC request. +type Request interface{} + +// Response is an RPC response. +type Response interface{} + +// Endpoint is the fundamental building block of package server. +// It represents a single RPC method. +type Endpoint func(context.Context, Request) (Response, error) + +// ErrBadCast indicates a type error during decoding or encoding. +var ErrBadCast = errors.New("bad cast") + +// ErrContextCanceled indicates a controlling context was canceled before the +// request could be served. +var ErrContextCanceled = errors.New("context was canceled") diff --git a/tracing/zipkin/_thrift/compile.sh b/tracing/zipkin/_thrift/compile.sh new file mode 100755 index 000000000..5b88bbfb3 --- /dev/null +++ b/tracing/zipkin/_thrift/compile.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +# Thrift code generation for Go is broken in the current stable (0.9.2) +# release. Leaving this stubbed out until the fix is released. +# https://issues.apache.org/jira/browse/THRIFT-3021 + +# https://thrift.apache.org/tutorial/go +for f in *.thrift ; do + thrift -r --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift $f +done + diff --git a/tracing/zipkin/_thrift/gen-go/scribe/constants.go b/tracing/zipkin/_thrift/gen-go/scribe/constants.go new file mode 100644 index 000000000..d814d4dd0 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/scribe/constants.go @@ -0,0 +1,18 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package scribe + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +func init() { +} diff --git a/tracing/zipkin/_thrift/gen-go/scribe/scribe-remote/scribe-remote.go b/tracing/zipkin/_thrift/gen-go/scribe/scribe-remote/scribe-remote.go new file mode 100755 index 000000000..dc4eafe3b --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/scribe/scribe-remote/scribe-remote.go @@ -0,0 +1,150 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package main + +import ( + "flag" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "math" + "net" + "net/url" + "os" + "scribe" + "strconv" + "strings" +) + +func Usage() { + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " ResultCode Log( messages)") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +func main() { + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + var parsedUrl url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Parse() + + if len(urlString) > 0 { + parsedUrl, err := url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransport(trans) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + client := scribe.NewScribeClientFactory(trans, protocolFactory) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "Log": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "Log requires 1 args") + flag.Usage() + } + arg5 := flag.Arg(1) + mbTrans6 := thrift.NewTMemoryBufferLen(len(arg5)) + defer mbTrans6.Close() + _, err7 := mbTrans6.WriteString(arg5) + if err7 != nil { + Usage() + return + } + factory8 := thrift.NewTSimpleJSONProtocolFactory() + jsProt9 := factory8.GetProtocol(mbTrans6) + containerStruct0 := scribe.NewLogArgs() + err10 := containerStruct0.ReadField1(jsProt9) + if err10 != nil { + Usage() + return + } + argvalue0 := containerStruct0.Messages + value0 := argvalue0 + fmt.Print(client.Log(value0)) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } +} diff --git a/tracing/zipkin/_thrift/gen-go/scribe/scribe.go b/tracing/zipkin/_thrift/gen-go/scribe/scribe.go new file mode 100644 index 000000000..44f60367c --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/scribe/scribe.go @@ -0,0 +1,418 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package scribe + +import ( + "bytes" + "fmt" + + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +type Scribe interface { + // Parameters: + // - Messages + Log(messages []*LogEntry) (r ResultCode, err error) +} + +type ScribeClient struct { + Transport thrift.TTransport + ProtocolFactory thrift.TProtocolFactory + InputProtocol thrift.TProtocol + OutputProtocol thrift.TProtocol + SeqId int32 +} + +func NewScribeClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ScribeClient { + return &ScribeClient{Transport: t, + ProtocolFactory: f, + InputProtocol: f.GetProtocol(t), + OutputProtocol: f.GetProtocol(t), + SeqId: 0, + } +} + +func NewScribeClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ScribeClient { + return &ScribeClient{Transport: t, + ProtocolFactory: nil, + InputProtocol: iprot, + OutputProtocol: oprot, + SeqId: 0, + } +} + +// Parameters: +// - Messages +func (p *ScribeClient) Log(messages []*LogEntry) (r ResultCode, err error) { + if err = p.sendLog(messages); err != nil { + return + } + return p.recvLog() +} + +func (p *ScribeClient) sendLog(messages []*LogEntry) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("Log", thrift.CALL, p.SeqId); err != nil { + return + } + args := LogArgs{ + Messages: messages, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ScribeClient) recvLog() (value ResultCode, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error1 error + error1, err = error0.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error1 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Log failed: out of sequence response") + return + } + result := LogResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + value = result.GetSuccess() + return +} + +type ScribeProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler Scribe +} + +func (p *ScribeProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *ScribeProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *ScribeProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewScribeProcessor(handler Scribe) *ScribeProcessor { + + self2 := &ScribeProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self2.processorMap["Log"] = &scribeProcessorLog{handler: handler} + return self2 +} + +func (p *ScribeProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x3.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, x3 + +} + +type scribeProcessorLog struct { + handler Scribe +} + +func (p *scribeProcessorLog) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := LogArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Log", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := LogResult{} + var retval ResultCode + var err2 error + if retval, err2 = p.handler.Log(args.Messages); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Log: "+err2.Error()) + oprot.WriteMessageBegin("Log", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } else { + result.Success = &retval + } + if err2 = oprot.WriteMessageBegin("Log", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +// HELPER FUNCTIONS AND STRUCTURES + +type LogArgs struct { + Messages []*LogEntry `thrift:"messages,1" json:"messages"` +} + +func NewLogArgs() *LogArgs { + return &LogArgs{} +} + +func (p *LogArgs) GetMessages() []*LogEntry { + return p.Messages +} +func (p *LogArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *LogArgs) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*LogEntry, 0, size) + p.Messages = tSlice + for i := 0; i < size; i++ { + _elem4 := &LogEntry{} + if err := _elem4.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem4, err) + } + p.Messages = append(p.Messages, _elem4) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *LogArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Log_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *LogArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("messages", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:messages: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Messages)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Messages { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:messages: %s", p, err) + } + return err +} + +func (p *LogArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("LogArgs(%+v)", *p) +} + +type LogResult struct { + Success *ResultCode `thrift:"success,0" json:"success"` +} + +func NewLogResult() *LogResult { + return &LogResult{} +} + +var LogResult_Success_DEFAULT ResultCode + +func (p *LogResult) GetSuccess() ResultCode { + if !p.IsSetSuccess() { + return LogResult_Success_DEFAULT + } + return *p.Success +} +func (p *LogResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *LogResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *LogResult) ReadField0(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + temp := ResultCode(v) + p.Success = &temp + } + return nil +} + +func (p *LogResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Log_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *LogResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteI32(int32(*p.Success)); err != nil { + return fmt.Errorf("%T.success (0) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *LogResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("LogResult(%+v)", *p) +} diff --git a/tracing/zipkin/_thrift/gen-go/scribe/ttypes.go b/tracing/zipkin/_thrift/gen-go/scribe/ttypes.go new file mode 100644 index 000000000..269989176 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/scribe/ttypes.go @@ -0,0 +1,168 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package scribe + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var GoUnusedProtection__ int + +type ResultCode int64 + +const ( + ResultCode_OK ResultCode = 0 + ResultCode_TRY_LATER ResultCode = 1 +) + +func (p ResultCode) String() string { + switch p { + case ResultCode_OK: + return "ResultCode_OK" + case ResultCode_TRY_LATER: + return "ResultCode_TRY_LATER" + } + return "" +} + +func ResultCodeFromString(s string) (ResultCode, error) { + switch s { + case "ResultCode_OK": + return ResultCode_OK, nil + case "ResultCode_TRY_LATER": + return ResultCode_TRY_LATER, nil + } + return ResultCode(0), fmt.Errorf("not a valid ResultCode string") +} + +func ResultCodePtr(v ResultCode) *ResultCode { return &v } + +type LogEntry struct { + Category string `thrift:"category,1" json:"category"` + Message string `thrift:"message,2" json:"message"` +} + +func NewLogEntry() *LogEntry { + return &LogEntry{} +} + +func (p *LogEntry) GetCategory() string { + return p.Category +} + +func (p *LogEntry) GetMessage() string { + return p.Message +} +func (p *LogEntry) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *LogEntry) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Category = v + } + return nil +} + +func (p *LogEntry) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.Message = v + } + return nil +} + +func (p *LogEntry) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("LogEntry"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *LogEntry) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("category", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:category: %s", p, err) + } + if err := oprot.WriteString(string(p.Category)); err != nil { + return fmt.Errorf("%T.category (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:category: %s", p, err) + } + return err +} + +func (p *LogEntry) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("message", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:message: %s", p, err) + } + if err := oprot.WriteString(string(p.Message)); err != nil { + return fmt.Errorf("%T.message (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:message: %s", p, err) + } + return err +} + +func (p *LogEntry) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("LogEntry(%+v)", *p) +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkincollector/constants.go b/tracing/zipkin/_thrift/gen-go/zipkincollector/constants.go new file mode 100644 index 000000000..4dddb68b9 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkincollector/constants.go @@ -0,0 +1,23 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkincollector + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "scribe" + "zipkindependencies" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = scribe.GoUnusedProtection__ +var _ = zipkindependencies.GoUnusedProtection__ + +func init() { +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkincollector/ttypes.go b/tracing/zipkin/_thrift/gen-go/zipkincollector/ttypes.go new file mode 100644 index 000000000..931d4c480 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkincollector/ttypes.go @@ -0,0 +1,205 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkincollector + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "scribe" + "zipkindependencies" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = scribe.GoUnusedProtection__ +var _ = zipkindependencies.GoUnusedProtection__ +var GoUnusedProtection__ int + +type AdjustableRateException struct { + Msg string `thrift:"msg,1" json:"msg"` +} + +func NewAdjustableRateException() *AdjustableRateException { + return &AdjustableRateException{} +} + +func (p *AdjustableRateException) GetMsg() string { + return p.Msg +} +func (p *AdjustableRateException) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *AdjustableRateException) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Msg = v + } + return nil +} + +func (p *AdjustableRateException) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("AdjustableRateException"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *AdjustableRateException) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:msg: %s", p, err) + } + if err := oprot.WriteString(string(p.Msg)); err != nil { + return fmt.Errorf("%T.msg (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:msg: %s", p, err) + } + return err +} + +func (p *AdjustableRateException) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AdjustableRateException(%+v)", *p) +} + +func (p *AdjustableRateException) Error() string { + return p.String() +} + +type StoreAggregatesException struct { + Msg string `thrift:"msg,1" json:"msg"` +} + +func NewStoreAggregatesException() *StoreAggregatesException { + return &StoreAggregatesException{} +} + +func (p *StoreAggregatesException) GetMsg() string { + return p.Msg +} +func (p *StoreAggregatesException) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *StoreAggregatesException) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Msg = v + } + return nil +} + +func (p *StoreAggregatesException) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("StoreAggregatesException"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *StoreAggregatesException) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:msg: %s", p, err) + } + if err := oprot.WriteString(string(p.Msg)); err != nil { + return fmt.Errorf("%T.msg (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:msg: %s", p, err) + } + return err +} + +func (p *StoreAggregatesException) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StoreAggregatesException(%+v)", *p) +} + +func (p *StoreAggregatesException) Error() string { + return p.String() +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkincollector/zipkin_collector-remote/zipkin_collector-remote.go b/tracing/zipkin/_thrift/gen-go/zipkincollector/zipkin_collector-remote/zipkin_collector-remote.go new file mode 100755 index 000000000..4602235a8 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkincollector/zipkin_collector-remote/zipkin_collector-remote.go @@ -0,0 +1,234 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package main + +import ( + "flag" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "math" + "net" + "net/url" + "os" + "strconv" + "strings" + "zipkincollector" +) + +func Usage() { + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " void storeTopAnnotations(string service_name, annotations)") + fmt.Fprintln(os.Stderr, " void storeTopKeyValueAnnotations(string service_name, annotations)") + fmt.Fprintln(os.Stderr, " void storeDependencies(Dependencies dependencies)") + fmt.Fprintln(os.Stderr, " ResultCode Log( messages)") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +func main() { + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + var parsedUrl url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Parse() + + if len(urlString) > 0 { + parsedUrl, err := url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransport(trans) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + client := zipkincollector.NewZipkinCollectorClientFactory(trans, protocolFactory) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "storeTopAnnotations": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "StoreTopAnnotations requires 2 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + arg10 := flag.Arg(2) + mbTrans11 := thrift.NewTMemoryBufferLen(len(arg10)) + defer mbTrans11.Close() + _, err12 := mbTrans11.WriteString(arg10) + if err12 != nil { + Usage() + return + } + factory13 := thrift.NewTSimpleJSONProtocolFactory() + jsProt14 := factory13.GetProtocol(mbTrans11) + containerStruct1 := zipkincollector.NewStoreTopAnnotationsArgs() + err15 := containerStruct1.ReadField2(jsProt14) + if err15 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Annotations + value1 := argvalue1 + fmt.Print(client.StoreTopAnnotations(value0, value1)) + fmt.Print("\n") + break + case "storeTopKeyValueAnnotations": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "StoreTopKeyValueAnnotations requires 2 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + arg17 := flag.Arg(2) + mbTrans18 := thrift.NewTMemoryBufferLen(len(arg17)) + defer mbTrans18.Close() + _, err19 := mbTrans18.WriteString(arg17) + if err19 != nil { + Usage() + return + } + factory20 := thrift.NewTSimpleJSONProtocolFactory() + jsProt21 := factory20.GetProtocol(mbTrans18) + containerStruct1 := zipkincollector.NewStoreTopKeyValueAnnotationsArgs() + err22 := containerStruct1.ReadField2(jsProt21) + if err22 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Annotations + value1 := argvalue1 + fmt.Print(client.StoreTopKeyValueAnnotations(value0, value1)) + fmt.Print("\n") + break + case "storeDependencies": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "StoreDependencies requires 1 args") + flag.Usage() + } + arg23 := flag.Arg(1) + mbTrans24 := thrift.NewTMemoryBufferLen(len(arg23)) + defer mbTrans24.Close() + _, err25 := mbTrans24.WriteString(arg23) + if err25 != nil { + Usage() + return + } + factory26 := thrift.NewTSimpleJSONProtocolFactory() + jsProt27 := factory26.GetProtocol(mbTrans24) + argvalue0 := zipkincollector.NewDependencies() + err28 := argvalue0.Read(jsProt27) + if err28 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.StoreDependencies(value0)) + fmt.Print("\n") + break + case "Log": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "Log requires 1 args") + flag.Usage() + } + arg29 := flag.Arg(1) + mbTrans30 := thrift.NewTMemoryBufferLen(len(arg29)) + defer mbTrans30.Close() + _, err31 := mbTrans30.WriteString(arg29) + if err31 != nil { + Usage() + return + } + factory32 := thrift.NewTSimpleJSONProtocolFactory() + jsProt33 := factory32.GetProtocol(mbTrans30) + containerStruct0 := zipkincollector.NewLogArgs() + err34 := containerStruct0.ReadField1(jsProt33) + if err34 != nil { + Usage() + return + } + argvalue0 := containerStruct0.Messages + value0 := argvalue0 + fmt.Print(client.Log(value0)) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkincollector/zipkincollector.go b/tracing/zipkin/_thrift/gen-go/zipkincollector/zipkincollector.go new file mode 100644 index 000000000..1724abea4 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkincollector/zipkincollector.go @@ -0,0 +1,1112 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkincollector + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "scribe" + "zipkindependencies" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = scribe.GoUnusedProtection__ +var _ = zipkindependencies.GoUnusedProtection__ + +type ZipkinCollector interface { + scribe.Scribe + + // Aggregates methods + // + // Parameters: + // - ServiceName + // - Annotations + StoreTopAnnotations(service_name string, annotations []string) (err error) + // Parameters: + // - ServiceName + // - Annotations + StoreTopKeyValueAnnotations(service_name string, annotations []string) (err error) + // Parameters: + // - Dependencies + StoreDependencies(dependencies *zipkindependencies.Dependencies) (err error) +} + +type ZipkinCollectorClient struct { + *scribe.ScribeClient +} + +func NewZipkinCollectorClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ZipkinCollectorClient { + return &ZipkinCollectorClient{ScribeClient: scribe.NewScribeClientFactory(t, f)} +} + +func NewZipkinCollectorClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ZipkinCollectorClient { + return &ZipkinCollectorClient{ScribeClient: scribe.NewScribeClientProtocol(t, iprot, oprot)} +} + +// Aggregates methods +// +// Parameters: +// - ServiceName +// - Annotations +func (p *ZipkinCollectorClient) StoreTopAnnotations(service_name string, annotations []string) (err error) { + if err = p.sendStoreTopAnnotations(service_name, annotations); err != nil { + return + } + return p.recvStoreTopAnnotations() +} + +func (p *ZipkinCollectorClient) sendStoreTopAnnotations(service_name string, annotations []string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("storeTopAnnotations", thrift.CALL, p.SeqId); err != nil { + return + } + args := StoreTopAnnotationsArgs{ + ServiceName: service_name, + Annotations: annotations, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinCollectorClient) recvStoreTopAnnotations() (err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error1 error + error1, err = error0.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error1 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "storeTopAnnotations failed: out of sequence response") + return + } + result := StoreTopAnnotationsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.E != nil { + err = result.E + return + } + return +} + +// Parameters: +// - ServiceName +// - Annotations +func (p *ZipkinCollectorClient) StoreTopKeyValueAnnotations(service_name string, annotations []string) (err error) { + if err = p.sendStoreTopKeyValueAnnotations(service_name, annotations); err != nil { + return + } + return p.recvStoreTopKeyValueAnnotations() +} + +func (p *ZipkinCollectorClient) sendStoreTopKeyValueAnnotations(service_name string, annotations []string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.CALL, p.SeqId); err != nil { + return + } + args := StoreTopKeyValueAnnotationsArgs{ + ServiceName: service_name, + Annotations: annotations, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinCollectorClient) recvStoreTopKeyValueAnnotations() (err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error2 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error3 error + error3, err = error2.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error3 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "storeTopKeyValueAnnotations failed: out of sequence response") + return + } + result := StoreTopKeyValueAnnotationsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.E != nil { + err = result.E + return + } + return +} + +// Parameters: +// - Dependencies +func (p *ZipkinCollectorClient) StoreDependencies(dependencies *zipkindependencies.Dependencies) (err error) { + if err = p.sendStoreDependencies(dependencies); err != nil { + return + } + return p.recvStoreDependencies() +} + +func (p *ZipkinCollectorClient) sendStoreDependencies(dependencies *zipkindependencies.Dependencies) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("storeDependencies", thrift.CALL, p.SeqId); err != nil { + return + } + args := StoreDependenciesArgs{ + Dependencies: dependencies, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinCollectorClient) recvStoreDependencies() (err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error4 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error5 error + error5, err = error4.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error5 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "storeDependencies failed: out of sequence response") + return + } + result := StoreDependenciesResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.E != nil { + err = result.E + return + } + return +} + +type ZipkinCollectorProcessor struct { + *scribe.ScribeProcessor +} + +func NewZipkinCollectorProcessor(handler ZipkinCollector) *ZipkinCollectorProcessor { + self6 := &ZipkinCollectorProcessor{scribe.NewScribeProcessor(handler)} + self6.AddToProcessorMap("storeTopAnnotations", &zipkinCollectorProcessorStoreTopAnnotations{handler: handler}) + self6.AddToProcessorMap("storeTopKeyValueAnnotations", &zipkinCollectorProcessorStoreTopKeyValueAnnotations{handler: handler}) + self6.AddToProcessorMap("storeDependencies", &zipkinCollectorProcessorStoreDependencies{handler: handler}) + return self6 +} + +type zipkinCollectorProcessorStoreTopAnnotations struct { + handler ZipkinCollector +} + +func (p *zipkinCollectorProcessorStoreTopAnnotations) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := StoreTopAnnotationsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("storeTopAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := StoreTopAnnotationsResult{} + var err2 error + if err2 = p.handler.StoreTopAnnotations(args.ServiceName, args.Annotations); err2 != nil { + switch v := err2.(type) { + case *StoreAggregatesException: + result.E = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing storeTopAnnotations: "+err2.Error()) + oprot.WriteMessageBegin("storeTopAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } + if err2 = oprot.WriteMessageBegin("storeTopAnnotations", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinCollectorProcessorStoreTopKeyValueAnnotations struct { + handler ZipkinCollector +} + +func (p *zipkinCollectorProcessorStoreTopKeyValueAnnotations) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := StoreTopKeyValueAnnotationsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := StoreTopKeyValueAnnotationsResult{} + var err2 error + if err2 = p.handler.StoreTopKeyValueAnnotations(args.ServiceName, args.Annotations); err2 != nil { + switch v := err2.(type) { + case *StoreAggregatesException: + result.E = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing storeTopKeyValueAnnotations: "+err2.Error()) + oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } + if err2 = oprot.WriteMessageBegin("storeTopKeyValueAnnotations", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinCollectorProcessorStoreDependencies struct { + handler ZipkinCollector +} + +func (p *zipkinCollectorProcessorStoreDependencies) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := StoreDependenciesArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("storeDependencies", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := StoreDependenciesResult{} + var err2 error + if err2 = p.handler.StoreDependencies(args.Dependencies); err2 != nil { + switch v := err2.(type) { + case *StoreAggregatesException: + result.E = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing storeDependencies: "+err2.Error()) + oprot.WriteMessageBegin("storeDependencies", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } + if err2 = oprot.WriteMessageBegin("storeDependencies", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +// HELPER FUNCTIONS AND STRUCTURES + +type StoreTopAnnotationsArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` + Annotations []string `thrift:"annotations,2" json:"annotations"` +} + +func NewStoreTopAnnotationsArgs() *StoreTopAnnotationsArgs { + return &StoreTopAnnotationsArgs{} +} + +func (p *StoreTopAnnotationsArgs) GetServiceName() string { + return p.ServiceName +} + +func (p *StoreTopAnnotationsArgs) GetAnnotations() []string { + return p.Annotations +} +func (p *StoreTopAnnotationsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *StoreTopAnnotationsArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *StoreTopAnnotationsArgs) ReadField2(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]string, 0, size) + p.Annotations = tSlice + for i := 0; i < size; i++ { + var _elem7 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem7 = v + } + p.Annotations = append(p.Annotations, _elem7) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *StoreTopAnnotationsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("storeTopAnnotations_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *StoreTopAnnotationsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *StoreTopAnnotationsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRING, len(p.Annotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Annotations { + if err := oprot.WriteString(string(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:annotations: %s", p, err) + } + return err +} + +func (p *StoreTopAnnotationsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StoreTopAnnotationsArgs(%+v)", *p) +} + +type StoreTopAnnotationsResult struct { + E *StoreAggregatesException `thrift:"e,1" json:"e"` +} + +func NewStoreTopAnnotationsResult() *StoreTopAnnotationsResult { + return &StoreTopAnnotationsResult{} +} + +var StoreTopAnnotationsResult_E_DEFAULT *StoreAggregatesException + +func (p *StoreTopAnnotationsResult) GetE() *StoreAggregatesException { + if !p.IsSetE() { + return StoreTopAnnotationsResult_E_DEFAULT + } + return p.E +} +func (p *StoreTopAnnotationsResult) IsSetE() bool { + return p.E != nil +} + +func (p *StoreTopAnnotationsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *StoreTopAnnotationsResult) ReadField1(iprot thrift.TProtocol) error { + p.E = &StoreAggregatesException{} + if err := p.E.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.E, err) + } + return nil +} + +func (p *StoreTopAnnotationsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("storeTopAnnotations_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *StoreTopAnnotationsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetE() { + if err := oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:e: %s", p, err) + } + if err := p.E.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.E, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:e: %s", p, err) + } + } + return err +} + +func (p *StoreTopAnnotationsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StoreTopAnnotationsResult(%+v)", *p) +} + +type StoreTopKeyValueAnnotationsArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` + Annotations []string `thrift:"annotations,2" json:"annotations"` +} + +func NewStoreTopKeyValueAnnotationsArgs() *StoreTopKeyValueAnnotationsArgs { + return &StoreTopKeyValueAnnotationsArgs{} +} + +func (p *StoreTopKeyValueAnnotationsArgs) GetServiceName() string { + return p.ServiceName +} + +func (p *StoreTopKeyValueAnnotationsArgs) GetAnnotations() []string { + return p.Annotations +} +func (p *StoreTopKeyValueAnnotationsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *StoreTopKeyValueAnnotationsArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *StoreTopKeyValueAnnotationsArgs) ReadField2(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]string, 0, size) + p.Annotations = tSlice + for i := 0; i < size; i++ { + var _elem8 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem8 = v + } + p.Annotations = append(p.Annotations, _elem8) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *StoreTopKeyValueAnnotationsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("storeTopKeyValueAnnotations_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *StoreTopKeyValueAnnotationsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *StoreTopKeyValueAnnotationsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRING, len(p.Annotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Annotations { + if err := oprot.WriteString(string(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:annotations: %s", p, err) + } + return err +} + +func (p *StoreTopKeyValueAnnotationsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StoreTopKeyValueAnnotationsArgs(%+v)", *p) +} + +type StoreTopKeyValueAnnotationsResult struct { + E *StoreAggregatesException `thrift:"e,1" json:"e"` +} + +func NewStoreTopKeyValueAnnotationsResult() *StoreTopKeyValueAnnotationsResult { + return &StoreTopKeyValueAnnotationsResult{} +} + +var StoreTopKeyValueAnnotationsResult_E_DEFAULT *StoreAggregatesException + +func (p *StoreTopKeyValueAnnotationsResult) GetE() *StoreAggregatesException { + if !p.IsSetE() { + return StoreTopKeyValueAnnotationsResult_E_DEFAULT + } + return p.E +} +func (p *StoreTopKeyValueAnnotationsResult) IsSetE() bool { + return p.E != nil +} + +func (p *StoreTopKeyValueAnnotationsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *StoreTopKeyValueAnnotationsResult) ReadField1(iprot thrift.TProtocol) error { + p.E = &StoreAggregatesException{} + if err := p.E.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.E, err) + } + return nil +} + +func (p *StoreTopKeyValueAnnotationsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("storeTopKeyValueAnnotations_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *StoreTopKeyValueAnnotationsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetE() { + if err := oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:e: %s", p, err) + } + if err := p.E.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.E, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:e: %s", p, err) + } + } + return err +} + +func (p *StoreTopKeyValueAnnotationsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StoreTopKeyValueAnnotationsResult(%+v)", *p) +} + +type StoreDependenciesArgs struct { + Dependencies *zipkindependencies.Dependencies `thrift:"dependencies,1" json:"dependencies"` +} + +func NewStoreDependenciesArgs() *StoreDependenciesArgs { + return &StoreDependenciesArgs{} +} + +var StoreDependenciesArgs_Dependencies_DEFAULT *zipkindependencies.Dependencies + +func (p *StoreDependenciesArgs) GetDependencies() *zipkindependencies.Dependencies { + if !p.IsSetDependencies() { + return StoreDependenciesArgs_Dependencies_DEFAULT + } + return p.Dependencies +} +func (p *StoreDependenciesArgs) IsSetDependencies() bool { + return p.Dependencies != nil +} + +func (p *StoreDependenciesArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *StoreDependenciesArgs) ReadField1(iprot thrift.TProtocol) error { + p.Dependencies = &zipkindependencies.Dependencies{} + if err := p.Dependencies.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Dependencies, err) + } + return nil +} + +func (p *StoreDependenciesArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("storeDependencies_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *StoreDependenciesArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("dependencies", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:dependencies: %s", p, err) + } + if err := p.Dependencies.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Dependencies, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:dependencies: %s", p, err) + } + return err +} + +func (p *StoreDependenciesArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StoreDependenciesArgs(%+v)", *p) +} + +type StoreDependenciesResult struct { + E *StoreAggregatesException `thrift:"e,1" json:"e"` +} + +func NewStoreDependenciesResult() *StoreDependenciesResult { + return &StoreDependenciesResult{} +} + +var StoreDependenciesResult_E_DEFAULT *StoreAggregatesException + +func (p *StoreDependenciesResult) GetE() *StoreAggregatesException { + if !p.IsSetE() { + return StoreDependenciesResult_E_DEFAULT + } + return p.E +} +func (p *StoreDependenciesResult) IsSetE() bool { + return p.E != nil +} + +func (p *StoreDependenciesResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *StoreDependenciesResult) ReadField1(iprot thrift.TProtocol) error { + p.E = &StoreAggregatesException{} + if err := p.E.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.E, err) + } + return nil +} + +func (p *StoreDependenciesResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("storeDependencies_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *StoreDependenciesResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetE() { + if err := oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:e: %s", p, err) + } + if err := p.E.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.E, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:e: %s", p, err) + } + } + return err +} + +func (p *StoreDependenciesResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StoreDependenciesResult(%+v)", *p) +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkincore/constants.go b/tracing/zipkin/_thrift/gen-go/zipkincore/constants.go new file mode 100644 index 000000000..5808fdf45 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkincore/constants.go @@ -0,0 +1,23 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkincore + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +const CLIENT_SEND = "cs" +const CLIENT_RECV = "cr" +const SERVER_SEND = "ss" +const SERVER_RECV = "sr" + +func init() { +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkincore/ttypes.go b/tracing/zipkin/_thrift/gen-go/zipkincore/ttypes.go new file mode 100644 index 000000000..365ed8ba0 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkincore/ttypes.go @@ -0,0 +1,990 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkincore + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var GoUnusedProtection__ int + +type AnnotationType int64 + +const ( + AnnotationType_BOOL AnnotationType = 0 + AnnotationType_BYTES AnnotationType = 1 + AnnotationType_I16 AnnotationType = 2 + AnnotationType_I32 AnnotationType = 3 + AnnotationType_I64 AnnotationType = 4 + AnnotationType_DOUBLE AnnotationType = 5 + AnnotationType_STRING AnnotationType = 6 +) + +func (p AnnotationType) String() string { + switch p { + case AnnotationType_BOOL: + return "AnnotationType_BOOL" + case AnnotationType_BYTES: + return "AnnotationType_BYTES" + case AnnotationType_I16: + return "AnnotationType_I16" + case AnnotationType_I32: + return "AnnotationType_I32" + case AnnotationType_I64: + return "AnnotationType_I64" + case AnnotationType_DOUBLE: + return "AnnotationType_DOUBLE" + case AnnotationType_STRING: + return "AnnotationType_STRING" + } + return "" +} + +func AnnotationTypeFromString(s string) (AnnotationType, error) { + switch s { + case "AnnotationType_BOOL": + return AnnotationType_BOOL, nil + case "AnnotationType_BYTES": + return AnnotationType_BYTES, nil + case "AnnotationType_I16": + return AnnotationType_I16, nil + case "AnnotationType_I32": + return AnnotationType_I32, nil + case "AnnotationType_I64": + return AnnotationType_I64, nil + case "AnnotationType_DOUBLE": + return AnnotationType_DOUBLE, nil + case "AnnotationType_STRING": + return AnnotationType_STRING, nil + } + return AnnotationType(0), fmt.Errorf("not a valid AnnotationType string") +} + +func AnnotationTypePtr(v AnnotationType) *AnnotationType { return &v } + +type Endpoint struct { + Ipv4 int32 `thrift:"ipv4,1" json:"ipv4"` + Port int16 `thrift:"port,2" json:"port"` + ServiceName string `thrift:"service_name,3" json:"service_name"` +} + +func NewEndpoint() *Endpoint { + return &Endpoint{} +} + +func (p *Endpoint) GetIpv4() int32 { + return p.Ipv4 +} + +func (p *Endpoint) GetPort() int16 { + return p.Port +} + +func (p *Endpoint) GetServiceName() string { + return p.ServiceName +} +func (p *Endpoint) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *Endpoint) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Ipv4 = v + } + return nil +} + +func (p *Endpoint) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI16(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.Port = v + } + return nil +} + +func (p *Endpoint) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *Endpoint) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Endpoint"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *Endpoint) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("ipv4", thrift.I32, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:ipv4: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Ipv4)); err != nil { + return fmt.Errorf("%T.ipv4 (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:ipv4: %s", p, err) + } + return err +} + +func (p *Endpoint) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("port", thrift.I16, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:port: %s", p, err) + } + if err := oprot.WriteI16(int16(p.Port)); err != nil { + return fmt.Errorf("%T.port (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:port: %s", p, err) + } + return err +} + +func (p *Endpoint) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:service_name: %s", p, err) + } + return err +} + +func (p *Endpoint) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Endpoint(%+v)", *p) +} + +type Annotation struct { + Timestamp int64 `thrift:"timestamp,1" json:"timestamp"` + Value string `thrift:"value,2" json:"value"` + Host *Endpoint `thrift:"host,3" json:"host"` + Duration *int32 `thrift:"duration,4" json:"duration"` +} + +func NewAnnotation() *Annotation { + return &Annotation{} +} + +func (p *Annotation) GetTimestamp() int64 { + return p.Timestamp +} + +func (p *Annotation) GetValue() string { + return p.Value +} + +var Annotation_Host_DEFAULT *Endpoint + +func (p *Annotation) GetHost() *Endpoint { + if !p.IsSetHost() { + return Annotation_Host_DEFAULT + } + return p.Host +} + +var Annotation_Duration_DEFAULT int32 + +func (p *Annotation) GetDuration() int32 { + if !p.IsSetDuration() { + return Annotation_Duration_DEFAULT + } + return *p.Duration +} +func (p *Annotation) IsSetHost() bool { + return p.Host != nil +} + +func (p *Annotation) IsSetDuration() bool { + return p.Duration != nil +} + +func (p *Annotation) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *Annotation) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Timestamp = v + } + return nil +} + +func (p *Annotation) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.Value = v + } + return nil +} + +func (p *Annotation) ReadField3(iprot thrift.TProtocol) error { + p.Host = &Endpoint{} + if err := p.Host.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Host, err) + } + return nil +} + +func (p *Annotation) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 4: %s", err) + } else { + p.Duration = &v + } + return nil +} + +func (p *Annotation) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Annotation"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *Annotation) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:timestamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.Timestamp)); err != nil { + return fmt.Errorf("%T.timestamp (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:timestamp: %s", p, err) + } + return err +} + +func (p *Annotation) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:value: %s", p, err) + } + if err := oprot.WriteString(string(p.Value)); err != nil { + return fmt.Errorf("%T.value (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:value: %s", p, err) + } + return err +} + +func (p *Annotation) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetHost() { + if err := oprot.WriteFieldBegin("host", thrift.STRUCT, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:host: %s", p, err) + } + if err := p.Host.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Host, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:host: %s", p, err) + } + } + return err +} + +func (p *Annotation) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetDuration() { + if err := oprot.WriteFieldBegin("duration", thrift.I32, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:duration: %s", p, err) + } + if err := oprot.WriteI32(int32(*p.Duration)); err != nil { + return fmt.Errorf("%T.duration (4) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:duration: %s", p, err) + } + } + return err +} + +func (p *Annotation) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Annotation(%+v)", *p) +} + +type BinaryAnnotation struct { + Key string `thrift:"key,1" json:"key"` + Value []byte `thrift:"value,2" json:"value"` + AnnotationType AnnotationType `thrift:"annotation_type,3" json:"annotation_type"` + Host *Endpoint `thrift:"host,4" json:"host"` +} + +func NewBinaryAnnotation() *BinaryAnnotation { + return &BinaryAnnotation{} +} + +func (p *BinaryAnnotation) GetKey() string { + return p.Key +} + +func (p *BinaryAnnotation) GetValue() []byte { + return p.Value +} + +func (p *BinaryAnnotation) GetAnnotationType() AnnotationType { + return p.AnnotationType +} + +var BinaryAnnotation_Host_DEFAULT *Endpoint + +func (p *BinaryAnnotation) GetHost() *Endpoint { + if !p.IsSetHost() { + return BinaryAnnotation_Host_DEFAULT + } + return p.Host +} +func (p *BinaryAnnotation) IsSetHost() bool { + return p.Host != nil +} + +func (p *BinaryAnnotation) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *BinaryAnnotation) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Key = v + } + return nil +} + +func (p *BinaryAnnotation) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.Value = v + } + return nil +} + +func (p *BinaryAnnotation) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + temp := AnnotationType(v) + p.AnnotationType = temp + } + return nil +} + +func (p *BinaryAnnotation) ReadField4(iprot thrift.TProtocol) error { + p.Host = &Endpoint{} + if err := p.Host.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Host, err) + } + return nil +} + +func (p *BinaryAnnotation) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("BinaryAnnotation"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *BinaryAnnotation) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("key", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:key: %s", p, err) + } + if err := oprot.WriteString(string(p.Key)); err != nil { + return fmt.Errorf("%T.key (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:key: %s", p, err) + } + return err +} + +func (p *BinaryAnnotation) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:value: %s", p, err) + } + if err := oprot.WriteBinary(p.Value); err != nil { + return fmt.Errorf("%T.value (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:value: %s", p, err) + } + return err +} + +func (p *BinaryAnnotation) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("annotation_type", thrift.I32, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:annotation_type: %s", p, err) + } + if err := oprot.WriteI32(int32(p.AnnotationType)); err != nil { + return fmt.Errorf("%T.annotation_type (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:annotation_type: %s", p, err) + } + return err +} + +func (p *BinaryAnnotation) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetHost() { + if err := oprot.WriteFieldBegin("host", thrift.STRUCT, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:host: %s", p, err) + } + if err := p.Host.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Host, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:host: %s", p, err) + } + } + return err +} + +func (p *BinaryAnnotation) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BinaryAnnotation(%+v)", *p) +} + +type Span struct { + TraceId int64 `thrift:"trace_id,1" json:"trace_id"` + // unused field # 2 + Name string `thrift:"name,3" json:"name"` + Id int64 `thrift:"id,4" json:"id"` + ParentId *int64 `thrift:"parent_id,5" json:"parent_id"` + Annotations []*Annotation `thrift:"annotations,6" json:"annotations"` + // unused field # 7 + BinaryAnnotations []*BinaryAnnotation `thrift:"binary_annotations,8" json:"binary_annotations"` + Debug bool `thrift:"debug,9" json:"debug"` +} + +func NewSpan() *Span { + return &Span{} +} + +func (p *Span) GetTraceId() int64 { + return p.TraceId +} + +func (p *Span) GetName() string { + return p.Name +} + +func (p *Span) GetId() int64 { + return p.Id +} + +var Span_ParentId_DEFAULT int64 + +func (p *Span) GetParentId() int64 { + if !p.IsSetParentId() { + return Span_ParentId_DEFAULT + } + return *p.ParentId +} + +func (p *Span) GetAnnotations() []*Annotation { + return p.Annotations +} + +func (p *Span) GetBinaryAnnotations() []*BinaryAnnotation { + return p.BinaryAnnotations +} + +var Span_Debug_DEFAULT bool = false + +func (p *Span) GetDebug() bool { + return p.Debug +} +func (p *Span) IsSetParentId() bool { + return p.ParentId != nil +} + +func (p *Span) IsSetDebug() bool { + return p.Debug != Span_Debug_DEFAULT +} + +func (p *Span) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + case 5: + if err := p.ReadField5(iprot); err != nil { + return err + } + case 6: + if err := p.ReadField6(iprot); err != nil { + return err + } + case 8: + if err := p.ReadField8(iprot); err != nil { + return err + } + case 9: + if err := p.ReadField9(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *Span) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.TraceId = v + } + return nil +} + +func (p *Span) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.Name = v + } + return nil +} + +func (p *Span) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 4: %s", err) + } else { + p.Id = v + } + return nil +} + +func (p *Span) ReadField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 5: %s", err) + } else { + p.ParentId = &v + } + return nil +} + +func (p *Span) ReadField6(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*Annotation, 0, size) + p.Annotations = tSlice + for i := 0; i < size; i++ { + _elem0 := &Annotation{} + if err := _elem0.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem0, err) + } + p.Annotations = append(p.Annotations, _elem0) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *Span) ReadField8(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*BinaryAnnotation, 0, size) + p.BinaryAnnotations = tSlice + for i := 0; i < size; i++ { + _elem1 := &BinaryAnnotation{} + if err := _elem1.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem1, err) + } + p.BinaryAnnotations = append(p.BinaryAnnotations, _elem1) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *Span) ReadField9(iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(); err != nil { + return fmt.Errorf("error reading field 9: %s", err) + } else { + p.Debug = v + } + return nil +} + +func (p *Span) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Span"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField8(oprot); err != nil { + return err + } + if err := p.writeField9(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *Span) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_id", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.TraceId)); err != nil { + return fmt.Errorf("%T.trace_id (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_id: %s", p, err) + } + return err +} + +func (p *Span) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("name", thrift.STRING, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:name: %s", p, err) + } + if err := oprot.WriteString(string(p.Name)); err != nil { + return fmt.Errorf("%T.name (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:name: %s", p, err) + } + return err +} + +func (p *Span) writeField4(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("id", thrift.I64, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.Id)); err != nil { + return fmt.Errorf("%T.id (4) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:id: %s", p, err) + } + return err +} + +func (p *Span) writeField5(oprot thrift.TProtocol) (err error) { + if p.IsSetParentId() { + if err := oprot.WriteFieldBegin("parent_id", thrift.I64, 5); err != nil { + return fmt.Errorf("%T write field begin error 5:parent_id: %s", p, err) + } + if err := oprot.WriteI64(int64(*p.ParentId)); err != nil { + return fmt.Errorf("%T.parent_id (5) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 5:parent_id: %s", p, err) + } + } + return err +} + +func (p *Span) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 6); err != nil { + return fmt.Errorf("%T write field begin error 6:annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Annotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Annotations { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 6:annotations: %s", p, err) + } + return err +} + +func (p *Span) writeField8(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("binary_annotations", thrift.LIST, 8); err != nil { + return fmt.Errorf("%T write field begin error 8:binary_annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.BinaryAnnotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.BinaryAnnotations { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 8:binary_annotations: %s", p, err) + } + return err +} + +func (p *Span) writeField9(oprot thrift.TProtocol) (err error) { + if p.IsSetDebug() { + if err := oprot.WriteFieldBegin("debug", thrift.BOOL, 9); err != nil { + return fmt.Errorf("%T write field begin error 9:debug: %s", p, err) + } + if err := oprot.WriteBool(bool(p.Debug)); err != nil { + return fmt.Errorf("%T.debug (9) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 9:debug: %s", p, err) + } + } + return err +} + +func (p *Span) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Span(%+v)", *p) +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkindependencies/constants.go b/tracing/zipkin/_thrift/gen-go/zipkindependencies/constants.go new file mode 100644 index 000000000..16d060abb --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkindependencies/constants.go @@ -0,0 +1,18 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkindependencies + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +func init() { +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkindependencies/ttypes.go b/tracing/zipkin/_thrift/gen-go/zipkindependencies/ttypes.go new file mode 100644 index 000000000..b4de42e51 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkindependencies/ttypes.go @@ -0,0 +1,580 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkindependencies + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var GoUnusedProtection__ int + +type Moments struct { + M0 int64 `thrift:"m0,1" json:"m0"` + M1 float64 `thrift:"m1,2" json:"m1"` + M2 float64 `thrift:"m2,3" json:"m2"` + M3 float64 `thrift:"m3,4" json:"m3"` + M4 float64 `thrift:"m4,5" json:"m4"` +} + +func NewMoments() *Moments { + return &Moments{} +} + +func (p *Moments) GetM0() int64 { + return p.M0 +} + +func (p *Moments) GetM1() float64 { + return p.M1 +} + +func (p *Moments) GetM2() float64 { + return p.M2 +} + +func (p *Moments) GetM3() float64 { + return p.M3 +} + +func (p *Moments) GetM4() float64 { + return p.M4 +} +func (p *Moments) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + case 5: + if err := p.ReadField5(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *Moments) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.M0 = v + } + return nil +} + +func (p *Moments) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.M1 = v + } + return nil +} + +func (p *Moments) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.M2 = v + } + return nil +} + +func (p *Moments) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(); err != nil { + return fmt.Errorf("error reading field 4: %s", err) + } else { + p.M3 = v + } + return nil +} + +func (p *Moments) ReadField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(); err != nil { + return fmt.Errorf("error reading field 5: %s", err) + } else { + p.M4 = v + } + return nil +} + +func (p *Moments) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Moments"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *Moments) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("m0", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:m0: %s", p, err) + } + if err := oprot.WriteI64(int64(p.M0)); err != nil { + return fmt.Errorf("%T.m0 (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:m0: %s", p, err) + } + return err +} + +func (p *Moments) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("m1", thrift.DOUBLE, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:m1: %s", p, err) + } + if err := oprot.WriteDouble(float64(p.M1)); err != nil { + return fmt.Errorf("%T.m1 (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:m1: %s", p, err) + } + return err +} + +func (p *Moments) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("m2", thrift.DOUBLE, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:m2: %s", p, err) + } + if err := oprot.WriteDouble(float64(p.M2)); err != nil { + return fmt.Errorf("%T.m2 (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:m2: %s", p, err) + } + return err +} + +func (p *Moments) writeField4(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("m3", thrift.DOUBLE, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:m3: %s", p, err) + } + if err := oprot.WriteDouble(float64(p.M3)); err != nil { + return fmt.Errorf("%T.m3 (4) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:m3: %s", p, err) + } + return err +} + +func (p *Moments) writeField5(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("m4", thrift.DOUBLE, 5); err != nil { + return fmt.Errorf("%T write field begin error 5:m4: %s", p, err) + } + if err := oprot.WriteDouble(float64(p.M4)); err != nil { + return fmt.Errorf("%T.m4 (5) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 5:m4: %s", p, err) + } + return err +} + +func (p *Moments) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Moments(%+v)", *p) +} + +type DependencyLink struct { + Parent string `thrift:"parent,1" json:"parent"` + Child string `thrift:"child,2" json:"child"` + DurationMoments *Moments `thrift:"duration_moments,3" json:"duration_moments"` +} + +func NewDependencyLink() *DependencyLink { + return &DependencyLink{} +} + +func (p *DependencyLink) GetParent() string { + return p.Parent +} + +func (p *DependencyLink) GetChild() string { + return p.Child +} + +var DependencyLink_DurationMoments_DEFAULT *Moments + +func (p *DependencyLink) GetDurationMoments() *Moments { + if !p.IsSetDurationMoments() { + return DependencyLink_DurationMoments_DEFAULT + } + return p.DurationMoments +} +func (p *DependencyLink) IsSetDurationMoments() bool { + return p.DurationMoments != nil +} + +func (p *DependencyLink) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *DependencyLink) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Parent = v + } + return nil +} + +func (p *DependencyLink) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.Child = v + } + return nil +} + +func (p *DependencyLink) ReadField3(iprot thrift.TProtocol) error { + p.DurationMoments = &Moments{} + if err := p.DurationMoments.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.DurationMoments, err) + } + return nil +} + +func (p *DependencyLink) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("DependencyLink"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *DependencyLink) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("parent", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:parent: %s", p, err) + } + if err := oprot.WriteString(string(p.Parent)); err != nil { + return fmt.Errorf("%T.parent (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:parent: %s", p, err) + } + return err +} + +func (p *DependencyLink) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("child", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:child: %s", p, err) + } + if err := oprot.WriteString(string(p.Child)); err != nil { + return fmt.Errorf("%T.child (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:child: %s", p, err) + } + return err +} + +func (p *DependencyLink) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("duration_moments", thrift.STRUCT, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:duration_moments: %s", p, err) + } + if err := p.DurationMoments.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.DurationMoments, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:duration_moments: %s", p, err) + } + return err +} + +func (p *DependencyLink) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("DependencyLink(%+v)", *p) +} + +type Dependencies struct { + StartTime int64 `thrift:"start_time,1" json:"start_time"` + EndTime int64 `thrift:"end_time,2" json:"end_time"` + Links []*DependencyLink `thrift:"links,3" json:"links"` +} + +func NewDependencies() *Dependencies { + return &Dependencies{} +} + +func (p *Dependencies) GetStartTime() int64 { + return p.StartTime +} + +func (p *Dependencies) GetEndTime() int64 { + return p.EndTime +} + +func (p *Dependencies) GetLinks() []*DependencyLink { + return p.Links +} +func (p *Dependencies) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *Dependencies) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.StartTime = v + } + return nil +} + +func (p *Dependencies) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.EndTime = v + } + return nil +} + +func (p *Dependencies) ReadField3(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*DependencyLink, 0, size) + p.Links = tSlice + for i := 0; i < size; i++ { + _elem0 := &DependencyLink{} + if err := _elem0.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem0, err) + } + p.Links = append(p.Links, _elem0) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *Dependencies) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Dependencies"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *Dependencies) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("start_time", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:start_time: %s", p, err) + } + if err := oprot.WriteI64(int64(p.StartTime)); err != nil { + return fmt.Errorf("%T.start_time (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:start_time: %s", p, err) + } + return err +} + +func (p *Dependencies) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_time", thrift.I64, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:end_time: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTime)); err != nil { + return fmt.Errorf("%T.end_time (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:end_time: %s", p, err) + } + return err +} + +func (p *Dependencies) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("links", thrift.LIST, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:links: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Links)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Links { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:links: %s", p, err) + } + return err +} + +func (p *Dependencies) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Dependencies(%+v)", *p) +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkinquery/constants.go b/tracing/zipkin/_thrift/gen-go/zipkinquery/constants.go new file mode 100644 index 000000000..5c176e66f --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkinquery/constants.go @@ -0,0 +1,23 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkinquery + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "zipkincore" + "zipkindependencies" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = zipkincore.GoUnusedProtection__ +var _ = zipkindependencies.GoUnusedProtection__ + +func init() { +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkinquery/ttypes.go b/tracing/zipkin/_thrift/gen-go/zipkinquery/ttypes.go new file mode 100644 index 000000000..1fedbd6e7 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkinquery/ttypes.go @@ -0,0 +1,2085 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkinquery + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "zipkincore" + "zipkindependencies" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = zipkincore.GoUnusedProtection__ +var _ = zipkindependencies.GoUnusedProtection__ +var GoUnusedProtection__ int + +type Order int64 + +const ( + Order_TIMESTAMP_DESC Order = 0 + Order_TIMESTAMP_ASC Order = 1 + Order_DURATION_ASC Order = 2 + Order_DURATION_DESC Order = 3 + Order_NONE Order = 4 +) + +func (p Order) String() string { + switch p { + case Order_TIMESTAMP_DESC: + return "Order_TIMESTAMP_DESC" + case Order_TIMESTAMP_ASC: + return "Order_TIMESTAMP_ASC" + case Order_DURATION_ASC: + return "Order_DURATION_ASC" + case Order_DURATION_DESC: + return "Order_DURATION_DESC" + case Order_NONE: + return "Order_NONE" + } + return "" +} + +func OrderFromString(s string) (Order, error) { + switch s { + case "Order_TIMESTAMP_DESC": + return Order_TIMESTAMP_DESC, nil + case "Order_TIMESTAMP_ASC": + return Order_TIMESTAMP_ASC, nil + case "Order_DURATION_ASC": + return Order_DURATION_ASC, nil + case "Order_DURATION_DESC": + return Order_DURATION_DESC, nil + case "Order_NONE": + return Order_NONE, nil + } + return Order(0), fmt.Errorf("not a valid Order string") +} + +func OrderPtr(v Order) *Order { return &v } + +//The raw data in our storage might have various problems. How should we adjust it before +//returning it to the user? +// +//Time skew adjuster tries to make sure that even though servers might have slightly +//different clocks the annotations in the returned data are adjusted so that they are +//in the correct order. +type Adjust int64 + +const ( + Adjust_NOTHING Adjust = 0 + Adjust_TIME_SKEW Adjust = 1 +) + +func (p Adjust) String() string { + switch p { + case Adjust_NOTHING: + return "Adjust_NOTHING" + case Adjust_TIME_SKEW: + return "Adjust_TIME_SKEW" + } + return "" +} + +func AdjustFromString(s string) (Adjust, error) { + switch s { + case "Adjust_NOTHING": + return Adjust_NOTHING, nil + case "Adjust_TIME_SKEW": + return Adjust_TIME_SKEW, nil + } + return Adjust(0), fmt.Errorf("not a valid Adjust string") +} + +func AdjustPtr(v Adjust) *Adjust { return &v } + +type Trace struct { + Spans []*zipkincore.Span `thrift:"spans,1" json:"spans"` +} + +func NewTrace() *Trace { + return &Trace{} +} + +func (p *Trace) GetSpans() []*zipkincore.Span { + return p.Spans +} +func (p *Trace) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *Trace) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*zipkincore.Span, 0, size) + p.Spans = tSlice + for i := 0; i < size; i++ { + _elem0 := &zipkincore.Span{} + if err := _elem0.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem0, err) + } + p.Spans = append(p.Spans, _elem0) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *Trace) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Trace"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *Trace) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("spans", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:spans: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Spans)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Spans { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:spans: %s", p, err) + } + return err +} + +func (p *Trace) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Trace(%+v)", *p) +} + +type QueryException struct { + Msg string `thrift:"msg,1" json:"msg"` +} + +func NewQueryException() *QueryException { + return &QueryException{} +} + +func (p *QueryException) GetMsg() string { + return p.Msg +} +func (p *QueryException) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *QueryException) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Msg = v + } + return nil +} + +func (p *QueryException) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("QueryException"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *QueryException) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("msg", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:msg: %s", p, err) + } + if err := oprot.WriteString(string(p.Msg)); err != nil { + return fmt.Errorf("%T.msg (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:msg: %s", p, err) + } + return err +} + +func (p *QueryException) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("QueryException(%+v)", *p) +} + +func (p *QueryException) Error() string { + return p.String() +} + +type SpanTimestamp struct { + Name string `thrift:"name,1" json:"name"` + StartTimestamp int64 `thrift:"start_timestamp,2" json:"start_timestamp"` + EndTimestamp int64 `thrift:"end_timestamp,3" json:"end_timestamp"` +} + +func NewSpanTimestamp() *SpanTimestamp { + return &SpanTimestamp{} +} + +func (p *SpanTimestamp) GetName() string { + return p.Name +} + +func (p *SpanTimestamp) GetStartTimestamp() int64 { + return p.StartTimestamp +} + +func (p *SpanTimestamp) GetEndTimestamp() int64 { + return p.EndTimestamp +} +func (p *SpanTimestamp) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *SpanTimestamp) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Name = v + } + return nil +} + +func (p *SpanTimestamp) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.StartTimestamp = v + } + return nil +} + +func (p *SpanTimestamp) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.EndTimestamp = v + } + return nil +} + +func (p *SpanTimestamp) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("SpanTimestamp"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *SpanTimestamp) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:name: %s", p, err) + } + if err := oprot.WriteString(string(p.Name)); err != nil { + return fmt.Errorf("%T.name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:name: %s", p, err) + } + return err +} + +func (p *SpanTimestamp) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("start_timestamp", thrift.I64, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:start_timestamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.StartTimestamp)); err != nil { + return fmt.Errorf("%T.start_timestamp (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:start_timestamp: %s", p, err) + } + return err +} + +func (p *SpanTimestamp) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_timestamp", thrift.I64, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:end_timestamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTimestamp)); err != nil { + return fmt.Errorf("%T.end_timestamp (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:end_timestamp: %s", p, err) + } + return err +} + +func (p *SpanTimestamp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SpanTimestamp(%+v)", *p) +} + +type TraceSummary struct { + TraceId int64 `thrift:"trace_id,1" json:"trace_id"` + StartTimestamp int64 `thrift:"start_timestamp,2" json:"start_timestamp"` + EndTimestamp int64 `thrift:"end_timestamp,3" json:"end_timestamp"` + DurationMicro int32 `thrift:"duration_micro,4" json:"duration_micro"` + // unused field # 5 + Endpoints []*zipkincore.Endpoint `thrift:"endpoints,6" json:"endpoints"` + SpanTimestamps []*SpanTimestamp `thrift:"span_timestamps,7" json:"span_timestamps"` +} + +func NewTraceSummary() *TraceSummary { + return &TraceSummary{} +} + +func (p *TraceSummary) GetTraceId() int64 { + return p.TraceId +} + +func (p *TraceSummary) GetStartTimestamp() int64 { + return p.StartTimestamp +} + +func (p *TraceSummary) GetEndTimestamp() int64 { + return p.EndTimestamp +} + +func (p *TraceSummary) GetDurationMicro() int32 { + return p.DurationMicro +} + +func (p *TraceSummary) GetEndpoints() []*zipkincore.Endpoint { + return p.Endpoints +} + +func (p *TraceSummary) GetSpanTimestamps() []*SpanTimestamp { + return p.SpanTimestamps +} +func (p *TraceSummary) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + case 6: + if err := p.ReadField6(iprot); err != nil { + return err + } + case 7: + if err := p.ReadField7(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *TraceSummary) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.TraceId = v + } + return nil +} + +func (p *TraceSummary) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.StartTimestamp = v + } + return nil +} + +func (p *TraceSummary) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.EndTimestamp = v + } + return nil +} + +func (p *TraceSummary) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 4: %s", err) + } else { + p.DurationMicro = v + } + return nil +} + +func (p *TraceSummary) ReadField6(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*zipkincore.Endpoint, 0, size) + p.Endpoints = tSlice + for i := 0; i < size; i++ { + _elem1 := &zipkincore.Endpoint{} + if err := _elem1.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem1, err) + } + p.Endpoints = append(p.Endpoints, _elem1) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *TraceSummary) ReadField7(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*SpanTimestamp, 0, size) + p.SpanTimestamps = tSlice + for i := 0; i < size; i++ { + _elem2 := &SpanTimestamp{} + if err := _elem2.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem2, err) + } + p.SpanTimestamps = append(p.SpanTimestamps, _elem2) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *TraceSummary) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("TraceSummary"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField7(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *TraceSummary) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_id", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.TraceId)); err != nil { + return fmt.Errorf("%T.trace_id (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_id: %s", p, err) + } + return err +} + +func (p *TraceSummary) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("start_timestamp", thrift.I64, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:start_timestamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.StartTimestamp)); err != nil { + return fmt.Errorf("%T.start_timestamp (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:start_timestamp: %s", p, err) + } + return err +} + +func (p *TraceSummary) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_timestamp", thrift.I64, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:end_timestamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTimestamp)); err != nil { + return fmt.Errorf("%T.end_timestamp (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:end_timestamp: %s", p, err) + } + return err +} + +func (p *TraceSummary) writeField4(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("duration_micro", thrift.I32, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:duration_micro: %s", p, err) + } + if err := oprot.WriteI32(int32(p.DurationMicro)); err != nil { + return fmt.Errorf("%T.duration_micro (4) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:duration_micro: %s", p, err) + } + return err +} + +func (p *TraceSummary) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("endpoints", thrift.LIST, 6); err != nil { + return fmt.Errorf("%T write field begin error 6:endpoints: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Endpoints)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Endpoints { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 6:endpoints: %s", p, err) + } + return err +} + +func (p *TraceSummary) writeField7(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("span_timestamps", thrift.LIST, 7); err != nil { + return fmt.Errorf("%T write field begin error 7:span_timestamps: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.SpanTimestamps)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.SpanTimestamps { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 7:span_timestamps: %s", p, err) + } + return err +} + +func (p *TraceSummary) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TraceSummary(%+v)", *p) +} + +type TimelineAnnotation struct { + Timestamp int64 `thrift:"timestamp,1" json:"timestamp"` + Value string `thrift:"value,2" json:"value"` + Host *zipkincore.Endpoint `thrift:"host,3" json:"host"` + SpanId int64 `thrift:"span_id,4" json:"span_id"` + ParentId *int64 `thrift:"parent_id,5" json:"parent_id"` + ServiceName string `thrift:"service_name,6" json:"service_name"` + SpanName string `thrift:"span_name,7" json:"span_name"` +} + +func NewTimelineAnnotation() *TimelineAnnotation { + return &TimelineAnnotation{} +} + +func (p *TimelineAnnotation) GetTimestamp() int64 { + return p.Timestamp +} + +func (p *TimelineAnnotation) GetValue() string { + return p.Value +} + +var TimelineAnnotation_Host_DEFAULT *zipkincore.Endpoint + +func (p *TimelineAnnotation) GetHost() *zipkincore.Endpoint { + if !p.IsSetHost() { + return TimelineAnnotation_Host_DEFAULT + } + return p.Host +} + +func (p *TimelineAnnotation) GetSpanId() int64 { + return p.SpanId +} + +var TimelineAnnotation_ParentId_DEFAULT int64 + +func (p *TimelineAnnotation) GetParentId() int64 { + if !p.IsSetParentId() { + return TimelineAnnotation_ParentId_DEFAULT + } + return *p.ParentId +} + +func (p *TimelineAnnotation) GetServiceName() string { + return p.ServiceName +} + +func (p *TimelineAnnotation) GetSpanName() string { + return p.SpanName +} +func (p *TimelineAnnotation) IsSetHost() bool { + return p.Host != nil +} + +func (p *TimelineAnnotation) IsSetParentId() bool { + return p.ParentId != nil +} + +func (p *TimelineAnnotation) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + case 5: + if err := p.ReadField5(iprot); err != nil { + return err + } + case 6: + if err := p.ReadField6(iprot); err != nil { + return err + } + case 7: + if err := p.ReadField7(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *TimelineAnnotation) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.Timestamp = v + } + return nil +} + +func (p *TimelineAnnotation) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.Value = v + } + return nil +} + +func (p *TimelineAnnotation) ReadField3(iprot thrift.TProtocol) error { + p.Host = &zipkincore.Endpoint{} + if err := p.Host.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Host, err) + } + return nil +} + +func (p *TimelineAnnotation) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 4: %s", err) + } else { + p.SpanId = v + } + return nil +} + +func (p *TimelineAnnotation) ReadField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 5: %s", err) + } else { + p.ParentId = &v + } + return nil +} + +func (p *TimelineAnnotation) ReadField6(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 6: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *TimelineAnnotation) ReadField7(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 7: %s", err) + } else { + p.SpanName = v + } + return nil +} + +func (p *TimelineAnnotation) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("TimelineAnnotation"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField7(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *TimelineAnnotation) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:timestamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.Timestamp)); err != nil { + return fmt.Errorf("%T.timestamp (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:timestamp: %s", p, err) + } + return err +} + +func (p *TimelineAnnotation) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:value: %s", p, err) + } + if err := oprot.WriteString(string(p.Value)); err != nil { + return fmt.Errorf("%T.value (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:value: %s", p, err) + } + return err +} + +func (p *TimelineAnnotation) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("host", thrift.STRUCT, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:host: %s", p, err) + } + if err := p.Host.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Host, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:host: %s", p, err) + } + return err +} + +func (p *TimelineAnnotation) writeField4(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("span_id", thrift.I64, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:span_id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.SpanId)); err != nil { + return fmt.Errorf("%T.span_id (4) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:span_id: %s", p, err) + } + return err +} + +func (p *TimelineAnnotation) writeField5(oprot thrift.TProtocol) (err error) { + if p.IsSetParentId() { + if err := oprot.WriteFieldBegin("parent_id", thrift.I64, 5); err != nil { + return fmt.Errorf("%T write field begin error 5:parent_id: %s", p, err) + } + if err := oprot.WriteI64(int64(*p.ParentId)); err != nil { + return fmt.Errorf("%T.parent_id (5) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 5:parent_id: %s", p, err) + } + } + return err +} + +func (p *TimelineAnnotation) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 6); err != nil { + return fmt.Errorf("%T write field begin error 6:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (6) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 6:service_name: %s", p, err) + } + return err +} + +func (p *TimelineAnnotation) writeField7(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("span_name", thrift.STRING, 7); err != nil { + return fmt.Errorf("%T write field begin error 7:span_name: %s", p, err) + } + if err := oprot.WriteString(string(p.SpanName)); err != nil { + return fmt.Errorf("%T.span_name (7) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 7:span_name: %s", p, err) + } + return err +} + +func (p *TimelineAnnotation) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TimelineAnnotation(%+v)", *p) +} + +type TraceTimeline struct { + TraceId int64 `thrift:"trace_id,1" json:"trace_id"` + RootMostSpanId int64 `thrift:"root_most_span_id,2" json:"root_most_span_id"` + // unused fields # 3 to 5 + Annotations []*TimelineAnnotation `thrift:"annotations,6" json:"annotations"` + BinaryAnnotations []*zipkincore.BinaryAnnotation `thrift:"binary_annotations,7" json:"binary_annotations"` +} + +func NewTraceTimeline() *TraceTimeline { + return &TraceTimeline{} +} + +func (p *TraceTimeline) GetTraceId() int64 { + return p.TraceId +} + +func (p *TraceTimeline) GetRootMostSpanId() int64 { + return p.RootMostSpanId +} + +func (p *TraceTimeline) GetAnnotations() []*TimelineAnnotation { + return p.Annotations +} + +func (p *TraceTimeline) GetBinaryAnnotations() []*zipkincore.BinaryAnnotation { + return p.BinaryAnnotations +} +func (p *TraceTimeline) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 6: + if err := p.ReadField6(iprot); err != nil { + return err + } + case 7: + if err := p.ReadField7(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *TraceTimeline) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.TraceId = v + } + return nil +} + +func (p *TraceTimeline) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.RootMostSpanId = v + } + return nil +} + +func (p *TraceTimeline) ReadField6(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*TimelineAnnotation, 0, size) + p.Annotations = tSlice + for i := 0; i < size; i++ { + _elem3 := &TimelineAnnotation{} + if err := _elem3.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem3, err) + } + p.Annotations = append(p.Annotations, _elem3) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *TraceTimeline) ReadField7(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*zipkincore.BinaryAnnotation, 0, size) + p.BinaryAnnotations = tSlice + for i := 0; i < size; i++ { + _elem4 := &zipkincore.BinaryAnnotation{} + if err := _elem4.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem4, err) + } + p.BinaryAnnotations = append(p.BinaryAnnotations, _elem4) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *TraceTimeline) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("TraceTimeline"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField7(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *TraceTimeline) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_id", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.TraceId)); err != nil { + return fmt.Errorf("%T.trace_id (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_id: %s", p, err) + } + return err +} + +func (p *TraceTimeline) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("root_most_span_id", thrift.I64, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:root_most_span_id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.RootMostSpanId)); err != nil { + return fmt.Errorf("%T.root_most_span_id (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:root_most_span_id: %s", p, err) + } + return err +} + +func (p *TraceTimeline) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 6); err != nil { + return fmt.Errorf("%T write field begin error 6:annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Annotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Annotations { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 6:annotations: %s", p, err) + } + return err +} + +func (p *TraceTimeline) writeField7(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("binary_annotations", thrift.LIST, 7); err != nil { + return fmt.Errorf("%T write field begin error 7:binary_annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.BinaryAnnotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.BinaryAnnotations { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 7:binary_annotations: %s", p, err) + } + return err +} + +func (p *TraceTimeline) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TraceTimeline(%+v)", *p) +} + +type TraceCombo struct { + Trace *Trace `thrift:"trace,1" json:"trace"` + Summary *TraceSummary `thrift:"summary,2" json:"summary"` + Timeline *TraceTimeline `thrift:"timeline,3" json:"timeline"` + SpanDepths map[int64]int32 `thrift:"span_depths,4" json:"span_depths"` +} + +func NewTraceCombo() *TraceCombo { + return &TraceCombo{} +} + +var TraceCombo_Trace_DEFAULT *Trace + +func (p *TraceCombo) GetTrace() *Trace { + if !p.IsSetTrace() { + return TraceCombo_Trace_DEFAULT + } + return p.Trace +} + +var TraceCombo_Summary_DEFAULT *TraceSummary + +func (p *TraceCombo) GetSummary() *TraceSummary { + if !p.IsSetSummary() { + return TraceCombo_Summary_DEFAULT + } + return p.Summary +} + +var TraceCombo_Timeline_DEFAULT *TraceTimeline + +func (p *TraceCombo) GetTimeline() *TraceTimeline { + if !p.IsSetTimeline() { + return TraceCombo_Timeline_DEFAULT + } + return p.Timeline +} + +var TraceCombo_SpanDepths_DEFAULT map[int64]int32 + +func (p *TraceCombo) GetSpanDepths() map[int64]int32 { + return p.SpanDepths +} +func (p *TraceCombo) IsSetTrace() bool { + return p.Trace != nil +} + +func (p *TraceCombo) IsSetSummary() bool { + return p.Summary != nil +} + +func (p *TraceCombo) IsSetTimeline() bool { + return p.Timeline != nil +} + +func (p *TraceCombo) IsSetSpanDepths() bool { + return p.SpanDepths != nil +} + +func (p *TraceCombo) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *TraceCombo) ReadField1(iprot thrift.TProtocol) error { + p.Trace = &Trace{} + if err := p.Trace.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Trace, err) + } + return nil +} + +func (p *TraceCombo) ReadField2(iprot thrift.TProtocol) error { + p.Summary = &TraceSummary{} + if err := p.Summary.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Summary, err) + } + return nil +} + +func (p *TraceCombo) ReadField3(iprot thrift.TProtocol) error { + p.Timeline = &TraceTimeline{} + if err := p.Timeline.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Timeline, err) + } + return nil +} + +func (p *TraceCombo) ReadField4(iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return fmt.Errorf("error reading map begin: %s", err) + } + tMap := make(map[int64]int32, size) + p.SpanDepths = tMap + for i := 0; i < size; i++ { + var _key5 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _key5 = v + } + var _val6 int32 + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _val6 = v + } + p.SpanDepths[_key5] = _val6 + } + if err := iprot.ReadMapEnd(); err != nil { + return fmt.Errorf("error reading map end: %s", err) + } + return nil +} + +func (p *TraceCombo) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("TraceCombo"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *TraceCombo) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace: %s", p, err) + } + if err := p.Trace.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Trace, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace: %s", p, err) + } + return err +} + +func (p *TraceCombo) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetSummary() { + if err := oprot.WriteFieldBegin("summary", thrift.STRUCT, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:summary: %s", p, err) + } + if err := p.Summary.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Summary, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:summary: %s", p, err) + } + } + return err +} + +func (p *TraceCombo) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetTimeline() { + if err := oprot.WriteFieldBegin("timeline", thrift.STRUCT, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:timeline: %s", p, err) + } + if err := p.Timeline.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Timeline, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:timeline: %s", p, err) + } + } + return err +} + +func (p *TraceCombo) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetSpanDepths() { + if err := oprot.WriteFieldBegin("span_depths", thrift.MAP, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:span_depths: %s", p, err) + } + if err := oprot.WriteMapBegin(thrift.I64, thrift.I32, len(p.SpanDepths)); err != nil { + return fmt.Errorf("error writing map begin: %s", err) + } + for k, v := range p.SpanDepths { + if err := oprot.WriteI64(int64(k)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + if err := oprot.WriteI32(int32(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteMapEnd(); err != nil { + return fmt.Errorf("error writing map end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:span_depths: %s", p, err) + } + } + return err +} + +func (p *TraceCombo) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TraceCombo(%+v)", *p) +} + +type QueryRequest struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` + SpanName *string `thrift:"span_name,2" json:"span_name"` + Annotations []string `thrift:"annotations,3" json:"annotations"` + BinaryAnnotations []*zipkincore.BinaryAnnotation `thrift:"binary_annotations,4" json:"binary_annotations"` + EndTs int64 `thrift:"end_ts,5" json:"end_ts"` + Limit int32 `thrift:"limit,6" json:"limit"` + Order Order `thrift:"order,7" json:"order"` +} + +func NewQueryRequest() *QueryRequest { + return &QueryRequest{} +} + +func (p *QueryRequest) GetServiceName() string { + return p.ServiceName +} + +var QueryRequest_SpanName_DEFAULT string + +func (p *QueryRequest) GetSpanName() string { + if !p.IsSetSpanName() { + return QueryRequest_SpanName_DEFAULT + } + return *p.SpanName +} + +var QueryRequest_Annotations_DEFAULT []string + +func (p *QueryRequest) GetAnnotations() []string { + return p.Annotations +} + +var QueryRequest_BinaryAnnotations_DEFAULT []*zipkincore.BinaryAnnotation + +func (p *QueryRequest) GetBinaryAnnotations() []*zipkincore.BinaryAnnotation { + return p.BinaryAnnotations +} + +func (p *QueryRequest) GetEndTs() int64 { + return p.EndTs +} + +func (p *QueryRequest) GetLimit() int32 { + return p.Limit +} + +func (p *QueryRequest) GetOrder() Order { + return p.Order +} +func (p *QueryRequest) IsSetSpanName() bool { + return p.SpanName != nil +} + +func (p *QueryRequest) IsSetAnnotations() bool { + return p.Annotations != nil +} + +func (p *QueryRequest) IsSetBinaryAnnotations() bool { + return p.BinaryAnnotations != nil +} + +func (p *QueryRequest) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + case 5: + if err := p.ReadField5(iprot); err != nil { + return err + } + case 6: + if err := p.ReadField6(iprot); err != nil { + return err + } + case 7: + if err := p.ReadField7(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *QueryRequest) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *QueryRequest) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.SpanName = &v + } + return nil +} + +func (p *QueryRequest) ReadField3(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]string, 0, size) + p.Annotations = tSlice + for i := 0; i < size; i++ { + var _elem7 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem7 = v + } + p.Annotations = append(p.Annotations, _elem7) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *QueryRequest) ReadField4(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*zipkincore.BinaryAnnotation, 0, size) + p.BinaryAnnotations = tSlice + for i := 0; i < size; i++ { + _elem8 := &zipkincore.BinaryAnnotation{} + if err := _elem8.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem8, err) + } + p.BinaryAnnotations = append(p.BinaryAnnotations, _elem8) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *QueryRequest) ReadField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 5: %s", err) + } else { + p.EndTs = v + } + return nil +} + +func (p *QueryRequest) ReadField6(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 6: %s", err) + } else { + p.Limit = v + } + return nil +} + +func (p *QueryRequest) ReadField7(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 7: %s", err) + } else { + temp := Order(v) + p.Order = temp + } + return nil +} + +func (p *QueryRequest) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("QueryRequest"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField7(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *QueryRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *QueryRequest) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetSpanName() { + if err := oprot.WriteFieldBegin("span_name", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:span_name: %s", p, err) + } + if err := oprot.WriteString(string(*p.SpanName)); err != nil { + return fmt.Errorf("%T.span_name (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:span_name: %s", p, err) + } + } + return err +} + +func (p *QueryRequest) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetAnnotations() { + if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRING, len(p.Annotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Annotations { + if err := oprot.WriteString(string(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:annotations: %s", p, err) + } + } + return err +} + +func (p *QueryRequest) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetBinaryAnnotations() { + if err := oprot.WriteFieldBegin("binary_annotations", thrift.LIST, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:binary_annotations: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.BinaryAnnotations)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.BinaryAnnotations { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:binary_annotations: %s", p, err) + } + } + return err +} + +func (p *QueryRequest) writeField5(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_ts", thrift.I64, 5); err != nil { + return fmt.Errorf("%T write field begin error 5:end_ts: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTs)); err != nil { + return fmt.Errorf("%T.end_ts (5) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 5:end_ts: %s", p, err) + } + return err +} + +func (p *QueryRequest) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("limit", thrift.I32, 6); err != nil { + return fmt.Errorf("%T write field begin error 6:limit: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Limit)); err != nil { + return fmt.Errorf("%T.limit (6) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 6:limit: %s", p, err) + } + return err +} + +func (p *QueryRequest) writeField7(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("order", thrift.I32, 7); err != nil { + return fmt.Errorf("%T write field begin error 7:order: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Order)); err != nil { + return fmt.Errorf("%T.order (7) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 7:order: %s", p, err) + } + return err +} + +func (p *QueryRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("QueryRequest(%+v)", *p) +} + +type QueryResponse struct { + TraceIds []int64 `thrift:"trace_ids,1" json:"trace_ids"` + StartTs int64 `thrift:"start_ts,2" json:"start_ts"` + EndTs int64 `thrift:"end_ts,3" json:"end_ts"` +} + +func NewQueryResponse() *QueryResponse { + return &QueryResponse{} +} + +func (p *QueryResponse) GetTraceIds() []int64 { + return p.TraceIds +} + +func (p *QueryResponse) GetStartTs() int64 { + return p.StartTs +} + +func (p *QueryResponse) GetEndTs() int64 { + return p.EndTs +} +func (p *QueryResponse) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *QueryResponse) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.TraceIds = tSlice + for i := 0; i < size; i++ { + var _elem9 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem9 = v + } + p.TraceIds = append(p.TraceIds, _elem9) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *QueryResponse) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.StartTs = v + } + return nil +} + +func (p *QueryResponse) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.EndTs = v + } + return nil +} + +func (p *QueryResponse) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("QueryResponse"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *QueryResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_ids", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_ids: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.TraceIds)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.TraceIds { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_ids: %s", p, err) + } + return err +} + +func (p *QueryResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("start_ts", thrift.I64, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:start_ts: %s", p, err) + } + if err := oprot.WriteI64(int64(p.StartTs)); err != nil { + return fmt.Errorf("%T.start_ts (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:start_ts: %s", p, err) + } + return err +} + +func (p *QueryResponse) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_ts", thrift.I64, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:end_ts: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTs)); err != nil { + return fmt.Errorf("%T.end_ts (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:end_ts: %s", p, err) + } + return err +} + +func (p *QueryResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("QueryResponse(%+v)", *p) +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkinquery/zipkin_query-remote/zipkin_query-remote.go b/tracing/zipkin/_thrift/gen-go/zipkinquery/zipkin_query-remote/zipkin_query-remote.go new file mode 100755 index 000000000..332a2f0f4 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkinquery/zipkin_query-remote/zipkin_query-remote.go @@ -0,0 +1,602 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package main + +import ( + "flag" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "math" + "net" + "net/url" + "os" + "strconv" + "strings" + "zipkinquery" +) + +func Usage() { + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " QueryResponse getTraceIds(QueryRequest request)") + fmt.Fprintln(os.Stderr, " getTraceIdsBySpanName(string service_name, string span_name, i64 end_ts, i32 limit, Order order)") + fmt.Fprintln(os.Stderr, " getTraceIdsByServiceName(string service_name, i64 end_ts, i32 limit, Order order)") + fmt.Fprintln(os.Stderr, " getTraceIdsByAnnotation(string service_name, string annotation, string value, i64 end_ts, i32 limit, Order order)") + fmt.Fprintln(os.Stderr, " tracesExist( trace_ids)") + fmt.Fprintln(os.Stderr, " getTracesByIds( trace_ids, adjust)") + fmt.Fprintln(os.Stderr, " getTraceTimelinesByIds( trace_ids, adjust)") + fmt.Fprintln(os.Stderr, " getTraceSummariesByIds( trace_ids, adjust)") + fmt.Fprintln(os.Stderr, " getTraceCombosByIds( trace_ids, adjust)") + fmt.Fprintln(os.Stderr, " getServiceNames()") + fmt.Fprintln(os.Stderr, " getSpanNames(string service_name)") + fmt.Fprintln(os.Stderr, " void setTraceTimeToLive(i64 trace_id, i32 ttl_seconds)") + fmt.Fprintln(os.Stderr, " i32 getTraceTimeToLive(i64 trace_id)") + fmt.Fprintln(os.Stderr, " i32 getDataTimeToLive()") + fmt.Fprintln(os.Stderr, " Dependencies getDependencies(i64 start_time, i64 end_time)") + fmt.Fprintln(os.Stderr, " getTopAnnotations(string service_name)") + fmt.Fprintln(os.Stderr, " getTopKeyValueAnnotations(string service_name)") + fmt.Fprintln(os.Stderr, " getSpanDurations(i64 time_stamp, string service_name, string rpc_name)") + fmt.Fprintln(os.Stderr, " getServiceNamesToTraceIds(i64 time_stamp, string service_name, string rpc_name)") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +func main() { + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + var parsedUrl url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Parse() + + if len(urlString) > 0 { + parsedUrl, err := url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransport(trans) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + client := zipkinquery.NewZipkinQueryClientFactory(trans, protocolFactory) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "getTraceIds": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "GetTraceIds requires 1 args") + flag.Usage() + } + arg77 := flag.Arg(1) + mbTrans78 := thrift.NewTMemoryBufferLen(len(arg77)) + defer mbTrans78.Close() + _, err79 := mbTrans78.WriteString(arg77) + if err79 != nil { + Usage() + return + } + factory80 := thrift.NewTSimpleJSONProtocolFactory() + jsProt81 := factory80.GetProtocol(mbTrans78) + argvalue0 := zipkinquery.NewQueryRequest() + err82 := argvalue0.Read(jsProt81) + if err82 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTraceIds(value0)) + fmt.Print("\n") + break + case "getTraceIdsBySpanName": + if flag.NArg()-1 != 5 { + fmt.Fprintln(os.Stderr, "GetTraceIdsBySpanName requires 5 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + argvalue2, err85 := (strconv.ParseInt(flag.Arg(3), 10, 64)) + if err85 != nil { + Usage() + return + } + value2 := argvalue2 + tmp3, err86 := (strconv.Atoi(flag.Arg(4))) + if err86 != nil { + Usage() + return + } + argvalue3 := int32(tmp3) + value3 := argvalue3 + tmp4, err := (strconv.Atoi(flag.Arg(5))) + if err != nil { + Usage() + return + } + argvalue4 := zipkinquery.Order(tmp4) + value4 := argvalue4 + fmt.Print(client.GetTraceIdsBySpanName(value0, value1, value2, value3, value4)) + fmt.Print("\n") + break + case "getTraceIdsByServiceName": + if flag.NArg()-1 != 4 { + fmt.Fprintln(os.Stderr, "GetTraceIdsByServiceName requires 4 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + argvalue1, err88 := (strconv.ParseInt(flag.Arg(2), 10, 64)) + if err88 != nil { + Usage() + return + } + value1 := argvalue1 + tmp2, err89 := (strconv.Atoi(flag.Arg(3))) + if err89 != nil { + Usage() + return + } + argvalue2 := int32(tmp2) + value2 := argvalue2 + tmp3, err := (strconv.Atoi(flag.Arg(4))) + if err != nil { + Usage() + return + } + argvalue3 := zipkinquery.Order(tmp3) + value3 := argvalue3 + fmt.Print(client.GetTraceIdsByServiceName(value0, value1, value2, value3)) + fmt.Print("\n") + break + case "getTraceIdsByAnnotation": + if flag.NArg()-1 != 6 { + fmt.Fprintln(os.Stderr, "GetTraceIdsByAnnotation requires 6 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + argvalue2 := []byte(flag.Arg(3)) + value2 := argvalue2 + argvalue3, err93 := (strconv.ParseInt(flag.Arg(4), 10, 64)) + if err93 != nil { + Usage() + return + } + value3 := argvalue3 + tmp4, err94 := (strconv.Atoi(flag.Arg(5))) + if err94 != nil { + Usage() + return + } + argvalue4 := int32(tmp4) + value4 := argvalue4 + tmp5, err := (strconv.Atoi(flag.Arg(6))) + if err != nil { + Usage() + return + } + argvalue5 := zipkinquery.Order(tmp5) + value5 := argvalue5 + fmt.Print(client.GetTraceIdsByAnnotation(value0, value1, value2, value3, value4, value5)) + fmt.Print("\n") + break + case "tracesExist": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "TracesExist requires 1 args") + flag.Usage() + } + arg95 := flag.Arg(1) + mbTrans96 := thrift.NewTMemoryBufferLen(len(arg95)) + defer mbTrans96.Close() + _, err97 := mbTrans96.WriteString(arg95) + if err97 != nil { + Usage() + return + } + factory98 := thrift.NewTSimpleJSONProtocolFactory() + jsProt99 := factory98.GetProtocol(mbTrans96) + containerStruct0 := zipkinquery.NewTracesExistArgs() + err100 := containerStruct0.ReadField1(jsProt99) + if err100 != nil { + Usage() + return + } + argvalue0 := containerStruct0.TraceIds + value0 := argvalue0 + fmt.Print(client.TracesExist(value0)) + fmt.Print("\n") + break + case "getTracesByIds": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "GetTracesByIds requires 2 args") + flag.Usage() + } + arg101 := flag.Arg(1) + mbTrans102 := thrift.NewTMemoryBufferLen(len(arg101)) + defer mbTrans102.Close() + _, err103 := mbTrans102.WriteString(arg101) + if err103 != nil { + Usage() + return + } + factory104 := thrift.NewTSimpleJSONProtocolFactory() + jsProt105 := factory104.GetProtocol(mbTrans102) + containerStruct0 := zipkinquery.NewGetTracesByIdsArgs() + err106 := containerStruct0.ReadField1(jsProt105) + if err106 != nil { + Usage() + return + } + argvalue0 := containerStruct0.TraceIds + value0 := argvalue0 + arg107 := flag.Arg(2) + mbTrans108 := thrift.NewTMemoryBufferLen(len(arg107)) + defer mbTrans108.Close() + _, err109 := mbTrans108.WriteString(arg107) + if err109 != nil { + Usage() + return + } + factory110 := thrift.NewTSimpleJSONProtocolFactory() + jsProt111 := factory110.GetProtocol(mbTrans108) + containerStruct1 := zipkinquery.NewGetTracesByIdsArgs() + err112 := containerStruct1.ReadField2(jsProt111) + if err112 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Adjust + value1 := argvalue1 + fmt.Print(client.GetTracesByIds(value0, value1)) + fmt.Print("\n") + break + case "getTraceTimelinesByIds": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "GetTraceTimelinesByIds requires 2 args") + flag.Usage() + } + arg113 := flag.Arg(1) + mbTrans114 := thrift.NewTMemoryBufferLen(len(arg113)) + defer mbTrans114.Close() + _, err115 := mbTrans114.WriteString(arg113) + if err115 != nil { + Usage() + return + } + factory116 := thrift.NewTSimpleJSONProtocolFactory() + jsProt117 := factory116.GetProtocol(mbTrans114) + containerStruct0 := zipkinquery.NewGetTraceTimelinesByIdsArgs() + err118 := containerStruct0.ReadField1(jsProt117) + if err118 != nil { + Usage() + return + } + argvalue0 := containerStruct0.TraceIds + value0 := argvalue0 + arg119 := flag.Arg(2) + mbTrans120 := thrift.NewTMemoryBufferLen(len(arg119)) + defer mbTrans120.Close() + _, err121 := mbTrans120.WriteString(arg119) + if err121 != nil { + Usage() + return + } + factory122 := thrift.NewTSimpleJSONProtocolFactory() + jsProt123 := factory122.GetProtocol(mbTrans120) + containerStruct1 := zipkinquery.NewGetTraceTimelinesByIdsArgs() + err124 := containerStruct1.ReadField2(jsProt123) + if err124 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Adjust + value1 := argvalue1 + fmt.Print(client.GetTraceTimelinesByIds(value0, value1)) + fmt.Print("\n") + break + case "getTraceSummariesByIds": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "GetTraceSummariesByIds requires 2 args") + flag.Usage() + } + arg125 := flag.Arg(1) + mbTrans126 := thrift.NewTMemoryBufferLen(len(arg125)) + defer mbTrans126.Close() + _, err127 := mbTrans126.WriteString(arg125) + if err127 != nil { + Usage() + return + } + factory128 := thrift.NewTSimpleJSONProtocolFactory() + jsProt129 := factory128.GetProtocol(mbTrans126) + containerStruct0 := zipkinquery.NewGetTraceSummariesByIdsArgs() + err130 := containerStruct0.ReadField1(jsProt129) + if err130 != nil { + Usage() + return + } + argvalue0 := containerStruct0.TraceIds + value0 := argvalue0 + arg131 := flag.Arg(2) + mbTrans132 := thrift.NewTMemoryBufferLen(len(arg131)) + defer mbTrans132.Close() + _, err133 := mbTrans132.WriteString(arg131) + if err133 != nil { + Usage() + return + } + factory134 := thrift.NewTSimpleJSONProtocolFactory() + jsProt135 := factory134.GetProtocol(mbTrans132) + containerStruct1 := zipkinquery.NewGetTraceSummariesByIdsArgs() + err136 := containerStruct1.ReadField2(jsProt135) + if err136 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Adjust + value1 := argvalue1 + fmt.Print(client.GetTraceSummariesByIds(value0, value1)) + fmt.Print("\n") + break + case "getTraceCombosByIds": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "GetTraceCombosByIds requires 2 args") + flag.Usage() + } + arg137 := flag.Arg(1) + mbTrans138 := thrift.NewTMemoryBufferLen(len(arg137)) + defer mbTrans138.Close() + _, err139 := mbTrans138.WriteString(arg137) + if err139 != nil { + Usage() + return + } + factory140 := thrift.NewTSimpleJSONProtocolFactory() + jsProt141 := factory140.GetProtocol(mbTrans138) + containerStruct0 := zipkinquery.NewGetTraceCombosByIdsArgs() + err142 := containerStruct0.ReadField1(jsProt141) + if err142 != nil { + Usage() + return + } + argvalue0 := containerStruct0.TraceIds + value0 := argvalue0 + arg143 := flag.Arg(2) + mbTrans144 := thrift.NewTMemoryBufferLen(len(arg143)) + defer mbTrans144.Close() + _, err145 := mbTrans144.WriteString(arg143) + if err145 != nil { + Usage() + return + } + factory146 := thrift.NewTSimpleJSONProtocolFactory() + jsProt147 := factory146.GetProtocol(mbTrans144) + containerStruct1 := zipkinquery.NewGetTraceCombosByIdsArgs() + err148 := containerStruct1.ReadField2(jsProt147) + if err148 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Adjust + value1 := argvalue1 + fmt.Print(client.GetTraceCombosByIds(value0, value1)) + fmt.Print("\n") + break + case "getServiceNames": + if flag.NArg()-1 != 0 { + fmt.Fprintln(os.Stderr, "GetServiceNames requires 0 args") + flag.Usage() + } + fmt.Print(client.GetServiceNames()) + fmt.Print("\n") + break + case "getSpanNames": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "GetSpanNames requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetSpanNames(value0)) + fmt.Print("\n") + break + case "setTraceTimeToLive": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "SetTraceTimeToLive requires 2 args") + flag.Usage() + } + argvalue0, err150 := (strconv.ParseInt(flag.Arg(1), 10, 64)) + if err150 != nil { + Usage() + return + } + value0 := argvalue0 + tmp1, err151 := (strconv.Atoi(flag.Arg(2))) + if err151 != nil { + Usage() + return + } + argvalue1 := int32(tmp1) + value1 := argvalue1 + fmt.Print(client.SetTraceTimeToLive(value0, value1)) + fmt.Print("\n") + break + case "getTraceTimeToLive": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "GetTraceTimeToLive requires 1 args") + flag.Usage() + } + argvalue0, err152 := (strconv.ParseInt(flag.Arg(1), 10, 64)) + if err152 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTraceTimeToLive(value0)) + fmt.Print("\n") + break + case "getDataTimeToLive": + if flag.NArg()-1 != 0 { + fmt.Fprintln(os.Stderr, "GetDataTimeToLive requires 0 args") + flag.Usage() + } + fmt.Print(client.GetDataTimeToLive()) + fmt.Print("\n") + break + case "getDependencies": + if flag.NArg()-1 != 2 { + fmt.Fprintln(os.Stderr, "GetDependencies requires 2 args") + flag.Usage() + } + argvalue0, err153 := (strconv.ParseInt(flag.Arg(1), 10, 64)) + if err153 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1, err154 := (strconv.ParseInt(flag.Arg(2), 10, 64)) + if err154 != nil { + Usage() + return + } + value1 := argvalue1 + fmt.Print(client.GetDependencies(value0, value1)) + fmt.Print("\n") + break + case "getTopAnnotations": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "GetTopAnnotations requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetTopAnnotations(value0)) + fmt.Print("\n") + break + case "getTopKeyValueAnnotations": + if flag.NArg()-1 != 1 { + fmt.Fprintln(os.Stderr, "GetTopKeyValueAnnotations requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetTopKeyValueAnnotations(value0)) + fmt.Print("\n") + break + case "getSpanDurations": + if flag.NArg()-1 != 3 { + fmt.Fprintln(os.Stderr, "GetSpanDurations requires 3 args") + flag.Usage() + } + argvalue0, err157 := (strconv.ParseInt(flag.Arg(1), 10, 64)) + if err157 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + argvalue2 := flag.Arg(3) + value2 := argvalue2 + fmt.Print(client.GetSpanDurations(value0, value1, value2)) + fmt.Print("\n") + break + case "getServiceNamesToTraceIds": + if flag.NArg()-1 != 3 { + fmt.Fprintln(os.Stderr, "GetServiceNamesToTraceIds requires 3 args") + flag.Usage() + } + argvalue0, err160 := (strconv.ParseInt(flag.Arg(1), 10, 64)) + if err160 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + argvalue2 := flag.Arg(3) + value2 := argvalue2 + fmt.Print(client.GetServiceNamesToTraceIds(value0, value1, value2)) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } +} diff --git a/tracing/zipkin/_thrift/gen-go/zipkinquery/zipkinquery.go b/tracing/zipkin/_thrift/gen-go/zipkinquery/zipkinquery.go new file mode 100644 index 000000000..6fbd56052 --- /dev/null +++ b/tracing/zipkin/_thrift/gen-go/zipkinquery/zipkinquery.go @@ -0,0 +1,8183 @@ +// Autogenerated by Thrift Compiler (0.9.2) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package zipkinquery + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "zipkincore" + "zipkindependencies" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = zipkincore.GoUnusedProtection__ +var _ = zipkindependencies.GoUnusedProtection__ + +type ZipkinQuery interface { + // Parameters: + // - Request + GetTraceIds(request *QueryRequest) (r *QueryResponse, err error) + // Fetch trace ids by service and span name. + // Gets "limit" number of entries from before the "end_ts". + // + // Span name is optional. + // Timestamps are in microseconds. + // + // Parameters: + // - ServiceName + // - SpanName + // - EndTs + // - Limit + // - Order + GetTraceIdsBySpanName(service_name string, span_name string, end_ts int64, limit int32, order Order) (r []int64, err error) + // Fetch trace ids by service name. + // Gets "limit" number of entries from before the "end_ts". + // + // Timestamps are in microseconds. + // + // Parameters: + // - ServiceName + // - EndTs + // - Limit + // - Order + GetTraceIdsByServiceName(service_name string, end_ts int64, limit int32, order Order) (r []int64, err error) + // Fetch trace ids with a particular annotation. + // Gets "limit" number of entries from before the "end_ts". + // + // When requesting based on time based annotations only pass in the first parameter, "annotation" and leave out + // the second "value". If looking for a key-value binary annotation provide both, "annotation" is then the + // key in the key-value. + // + // Timestamps are in microseconds. + // + // Parameters: + // - ServiceName + // - Annotation + // - Value + // - EndTs + // - Limit + // - Order + GetTraceIdsByAnnotation(service_name string, annotation string, value []byte, end_ts int64, limit int32, order Order) (r []int64, err error) + // Get the traces that are in the database from the given list of trace ids. + // + // Parameters: + // - TraceIds + TracesExist(trace_ids []int64) (r map[int64]bool, err error) + // Get the full traces associated with the given trace ids. + // + // Second argument is a list of methods of adjusting the trace + // data before returning it. Can be empty. + // + // Parameters: + // - TraceIds + // - Adjust + GetTracesByIds(trace_ids []int64, adjust []Adjust) (r []*Trace, err error) + // Get the trace timelines associated with the given trace ids. + // This is a convenience method for users that just want to know + // the annotations and the (assumed) order they happened in. + // + // Second argument is a list of methods of adjusting the trace + // data before returning it. Can be empty. + // + // Note that if one of the trace ids does not have any data associated with it, it will not be + // represented in the output list. + // + // Parameters: + // - TraceIds + // - Adjust + GetTraceTimelinesByIds(trace_ids []int64, adjust []Adjust) (r []*TraceTimeline, err error) + // Fetch trace summaries for the given trace ids. + // + // Second argument is a list of methods of adjusting the trace + // data before returning it. Can be empty. + // + // Note that if one of the trace ids does not have any data associated with it, it will not be + // represented in the output list. + // + // Parameters: + // - TraceIds + // - Adjust + GetTraceSummariesByIds(trace_ids []int64, adjust []Adjust) (r []*TraceSummary, err error) + // Not content with just one of traces, summaries or timelines? Want it all? This is the method for you. + // + // Parameters: + // - TraceIds + // - Adjust + GetTraceCombosByIds(trace_ids []int64, adjust []Adjust) (r []*TraceCombo, err error) + // Fetch all the service names we have seen from now all the way back to the set ttl. + GetServiceNames() (r map[string]bool, err error) + // Get all the seen span names for a particular service, from now back until the set ttl. + // + // Parameters: + // - ServiceName + GetSpanNames(service_name string) (r map[string]bool, err error) + // Change the TTL of a trace. If we find an interesting trace we want to keep around for further + // investigation. + // + // Parameters: + // - TraceId + // - TtlSeconds + SetTraceTimeToLive(trace_id int64, ttl_seconds int32) (err error) + // Get the TTL in seconds of a specific trace. + // + // Parameters: + // - TraceId + GetTraceTimeToLive(trace_id int64) (r int32, err error) + // Get the data ttl. This is the number of seconds we keep the data around before deleting it. + GetDataTimeToLive() (r int32, err error) + // Get an aggregate representation of all services paired with every service they call in to. + // This includes information on call counts and mean/stdDev/etc of call durations. The two arguments + // specify epoch time in microseconds. The end time is optional and defaults to one day after the + // start time. + // + // Parameters: + // - StartTime + // - EndTime + GetDependencies(start_time int64, end_time int64) (r *zipkindependencies.Dependencies, err error) + // Parameters: + // - ServiceName + GetTopAnnotations(service_name string) (r []string, err error) + // Parameters: + // - ServiceName + GetTopKeyValueAnnotations(service_name string) (r []string, err error) + // Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired + // with the lists of every span duration (list) from the server to client. The lists of span durations + // include information on call counts and mean/stdDev/etc of call durations. + // + // The three arguments specify epoch time in microseconds, server side service name and rpc name. The return maps + // contains the key - client_service_name and value - list. + // + // Parameters: + // - TimeStamp + // - ServiceName + // - RpcName + GetSpanDurations(time_stamp int64, service_name string, rpc_name string) (r map[string][]int64, err error) + // Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired + // with the lists of every trace Ids (list) from the server to client. + // + // The three arguments specify epoch time in microseconds, server side service name and rpc name. The return maps + // contains the key - client_service_name and value - list. + // + // Parameters: + // - TimeStamp + // - ServiceName + // - RpcName + GetServiceNamesToTraceIds(time_stamp int64, service_name string, rpc_name string) (r map[string][]int64, err error) +} + +type ZipkinQueryClient struct { + Transport thrift.TTransport + ProtocolFactory thrift.TProtocolFactory + InputProtocol thrift.TProtocol + OutputProtocol thrift.TProtocol + SeqId int32 +} + +func NewZipkinQueryClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ZipkinQueryClient { + return &ZipkinQueryClient{Transport: t, + ProtocolFactory: f, + InputProtocol: f.GetProtocol(t), + OutputProtocol: f.GetProtocol(t), + SeqId: 0, + } +} + +func NewZipkinQueryClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ZipkinQueryClient { + return &ZipkinQueryClient{Transport: t, + ProtocolFactory: nil, + InputProtocol: iprot, + OutputProtocol: oprot, + SeqId: 0, + } +} + +// Parameters: +// - Request +func (p *ZipkinQueryClient) GetTraceIds(request *QueryRequest) (r *QueryResponse, err error) { + if err = p.sendGetTraceIds(request); err != nil { + return + } + return p.recvGetTraceIds() +} + +func (p *ZipkinQueryClient) sendGetTraceIds(request *QueryRequest) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceIds", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceIdsArgs{ + Request: request, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceIds() (value *QueryResponse, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error10 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error11 error + error11, err = error10.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error11 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceIds failed: out of sequence response") + return + } + result := GetTraceIdsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Fetch trace ids by service and span name. +// Gets "limit" number of entries from before the "end_ts". +// +// Span name is optional. +// Timestamps are in microseconds. +// +// Parameters: +// - ServiceName +// - SpanName +// - EndTs +// - Limit +// - Order +func (p *ZipkinQueryClient) GetTraceIdsBySpanName(service_name string, span_name string, end_ts int64, limit int32, order Order) (r []int64, err error) { + if err = p.sendGetTraceIdsBySpanName(service_name, span_name, end_ts, limit, order); err != nil { + return + } + return p.recvGetTraceIdsBySpanName() +} + +func (p *ZipkinQueryClient) sendGetTraceIdsBySpanName(service_name string, span_name string, end_ts int64, limit int32, order Order) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceIdsBySpanName", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceIdsBySpanNameArgs{ + ServiceName: service_name, + SpanName: span_name, + EndTs: end_ts, + Limit: limit, + Order: order, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceIdsBySpanName() (value []int64, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error12 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error13 error + error13, err = error12.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error13 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceIdsBySpanName failed: out of sequence response") + return + } + result := GetTraceIdsBySpanNameResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Fetch trace ids by service name. +// Gets "limit" number of entries from before the "end_ts". +// +// Timestamps are in microseconds. +// +// Parameters: +// - ServiceName +// - EndTs +// - Limit +// - Order +func (p *ZipkinQueryClient) GetTraceIdsByServiceName(service_name string, end_ts int64, limit int32, order Order) (r []int64, err error) { + if err = p.sendGetTraceIdsByServiceName(service_name, end_ts, limit, order); err != nil { + return + } + return p.recvGetTraceIdsByServiceName() +} + +func (p *ZipkinQueryClient) sendGetTraceIdsByServiceName(service_name string, end_ts int64, limit int32, order Order) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceIdsByServiceName", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceIdsByServiceNameArgs{ + ServiceName: service_name, + EndTs: end_ts, + Limit: limit, + Order: order, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceIdsByServiceName() (value []int64, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error14 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error15 error + error15, err = error14.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error15 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceIdsByServiceName failed: out of sequence response") + return + } + result := GetTraceIdsByServiceNameResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Fetch trace ids with a particular annotation. +// Gets "limit" number of entries from before the "end_ts". +// +// When requesting based on time based annotations only pass in the first parameter, "annotation" and leave out +// the second "value". If looking for a key-value binary annotation provide both, "annotation" is then the +// key in the key-value. +// +// Timestamps are in microseconds. +// +// Parameters: +// - ServiceName +// - Annotation +// - Value +// - EndTs +// - Limit +// - Order +func (p *ZipkinQueryClient) GetTraceIdsByAnnotation(service_name string, annotation string, value []byte, end_ts int64, limit int32, order Order) (r []int64, err error) { + if err = p.sendGetTraceIdsByAnnotation(service_name, annotation, value, end_ts, limit, order); err != nil { + return + } + return p.recvGetTraceIdsByAnnotation() +} + +func (p *ZipkinQueryClient) sendGetTraceIdsByAnnotation(service_name string, annotation string, value []byte, end_ts int64, limit int32, order Order) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceIdsByAnnotation", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceIdsByAnnotationArgs{ + ServiceName: service_name, + Annotation: annotation, + Value: value, + EndTs: end_ts, + Limit: limit, + Order: order, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceIdsByAnnotation() (value []int64, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error16 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error17 error + error17, err = error16.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error17 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceIdsByAnnotation failed: out of sequence response") + return + } + result := GetTraceIdsByAnnotationResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Get the traces that are in the database from the given list of trace ids. +// +// Parameters: +// - TraceIds +func (p *ZipkinQueryClient) TracesExist(trace_ids []int64) (r map[int64]bool, err error) { + if err = p.sendTracesExist(trace_ids); err != nil { + return + } + return p.recvTracesExist() +} + +func (p *ZipkinQueryClient) sendTracesExist(trace_ids []int64) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("tracesExist", thrift.CALL, p.SeqId); err != nil { + return + } + args := TracesExistArgs{ + TraceIds: trace_ids, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvTracesExist() (value map[int64]bool, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error18 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error19 error + error19, err = error18.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error19 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "tracesExist failed: out of sequence response") + return + } + result := TracesExistResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Get the full traces associated with the given trace ids. +// +// Second argument is a list of methods of adjusting the trace +// data before returning it. Can be empty. +// +// Parameters: +// - TraceIds +// - Adjust +func (p *ZipkinQueryClient) GetTracesByIds(trace_ids []int64, adjust []Adjust) (r []*Trace, err error) { + if err = p.sendGetTracesByIds(trace_ids, adjust); err != nil { + return + } + return p.recvGetTracesByIds() +} + +func (p *ZipkinQueryClient) sendGetTracesByIds(trace_ids []int64, adjust []Adjust) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTracesByIds", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTracesByIdsArgs{ + TraceIds: trace_ids, + Adjust: adjust, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTracesByIds() (value []*Trace, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error20 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error21 error + error21, err = error20.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error21 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTracesByIds failed: out of sequence response") + return + } + result := GetTracesByIdsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Get the trace timelines associated with the given trace ids. +// This is a convenience method for users that just want to know +// the annotations and the (assumed) order they happened in. +// +// Second argument is a list of methods of adjusting the trace +// data before returning it. Can be empty. +// +// Note that if one of the trace ids does not have any data associated with it, it will not be +// represented in the output list. +// +// Parameters: +// - TraceIds +// - Adjust +func (p *ZipkinQueryClient) GetTraceTimelinesByIds(trace_ids []int64, adjust []Adjust) (r []*TraceTimeline, err error) { + if err = p.sendGetTraceTimelinesByIds(trace_ids, adjust); err != nil { + return + } + return p.recvGetTraceTimelinesByIds() +} + +func (p *ZipkinQueryClient) sendGetTraceTimelinesByIds(trace_ids []int64, adjust []Adjust) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceTimelinesByIds", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceTimelinesByIdsArgs{ + TraceIds: trace_ids, + Adjust: adjust, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceTimelinesByIds() (value []*TraceTimeline, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error22 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error23 error + error23, err = error22.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error23 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceTimelinesByIds failed: out of sequence response") + return + } + result := GetTraceTimelinesByIdsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Fetch trace summaries for the given trace ids. +// +// Second argument is a list of methods of adjusting the trace +// data before returning it. Can be empty. +// +// Note that if one of the trace ids does not have any data associated with it, it will not be +// represented in the output list. +// +// Parameters: +// - TraceIds +// - Adjust +func (p *ZipkinQueryClient) GetTraceSummariesByIds(trace_ids []int64, adjust []Adjust) (r []*TraceSummary, err error) { + if err = p.sendGetTraceSummariesByIds(trace_ids, adjust); err != nil { + return + } + return p.recvGetTraceSummariesByIds() +} + +func (p *ZipkinQueryClient) sendGetTraceSummariesByIds(trace_ids []int64, adjust []Adjust) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceSummariesByIds", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceSummariesByIdsArgs{ + TraceIds: trace_ids, + Adjust: adjust, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceSummariesByIds() (value []*TraceSummary, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error24 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error25 error + error25, err = error24.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error25 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceSummariesByIds failed: out of sequence response") + return + } + result := GetTraceSummariesByIdsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Not content with just one of traces, summaries or timelines? Want it all? This is the method for you. +// +// Parameters: +// - TraceIds +// - Adjust +func (p *ZipkinQueryClient) GetTraceCombosByIds(trace_ids []int64, adjust []Adjust) (r []*TraceCombo, err error) { + if err = p.sendGetTraceCombosByIds(trace_ids, adjust); err != nil { + return + } + return p.recvGetTraceCombosByIds() +} + +func (p *ZipkinQueryClient) sendGetTraceCombosByIds(trace_ids []int64, adjust []Adjust) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceCombosByIds", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceCombosByIdsArgs{ + TraceIds: trace_ids, + Adjust: adjust, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceCombosByIds() (value []*TraceCombo, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error26 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error27 error + error27, err = error26.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error27 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceCombosByIds failed: out of sequence response") + return + } + result := GetTraceCombosByIdsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Fetch all the service names we have seen from now all the way back to the set ttl. +func (p *ZipkinQueryClient) GetServiceNames() (r map[string]bool, err error) { + if err = p.sendGetServiceNames(); err != nil { + return + } + return p.recvGetServiceNames() +} + +func (p *ZipkinQueryClient) sendGetServiceNames() (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getServiceNames", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetServiceNamesArgs{} + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetServiceNames() (value map[string]bool, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error28 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error29 error + error29, err = error28.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error29 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getServiceNames failed: out of sequence response") + return + } + result := GetServiceNamesResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Get all the seen span names for a particular service, from now back until the set ttl. +// +// Parameters: +// - ServiceName +func (p *ZipkinQueryClient) GetSpanNames(service_name string) (r map[string]bool, err error) { + if err = p.sendGetSpanNames(service_name); err != nil { + return + } + return p.recvGetSpanNames() +} + +func (p *ZipkinQueryClient) sendGetSpanNames(service_name string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getSpanNames", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetSpanNamesArgs{ + ServiceName: service_name, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetSpanNames() (value map[string]bool, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error30 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error31 error + error31, err = error30.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error31 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getSpanNames failed: out of sequence response") + return + } + result := GetSpanNamesResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Change the TTL of a trace. If we find an interesting trace we want to keep around for further +// investigation. +// +// Parameters: +// - TraceId +// - TtlSeconds +func (p *ZipkinQueryClient) SetTraceTimeToLive(trace_id int64, ttl_seconds int32) (err error) { + if err = p.sendSetTraceTimeToLive(trace_id, ttl_seconds); err != nil { + return + } + return p.recvSetTraceTimeToLive() +} + +func (p *ZipkinQueryClient) sendSetTraceTimeToLive(trace_id int64, ttl_seconds int32) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("setTraceTimeToLive", thrift.CALL, p.SeqId); err != nil { + return + } + args := SetTraceTimeToLiveArgs{ + TraceId: trace_id, + TtlSeconds: ttl_seconds, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvSetTraceTimeToLive() (err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error32 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error33 error + error33, err = error32.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error33 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "setTraceTimeToLive failed: out of sequence response") + return + } + result := SetTraceTimeToLiveResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + return +} + +// Get the TTL in seconds of a specific trace. +// +// Parameters: +// - TraceId +func (p *ZipkinQueryClient) GetTraceTimeToLive(trace_id int64) (r int32, err error) { + if err = p.sendGetTraceTimeToLive(trace_id); err != nil { + return + } + return p.recvGetTraceTimeToLive() +} + +func (p *ZipkinQueryClient) sendGetTraceTimeToLive(trace_id int64) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTraceTimeToLive", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTraceTimeToLiveArgs{ + TraceId: trace_id, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTraceTimeToLive() (value int32, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error34 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error35 error + error35, err = error34.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error35 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTraceTimeToLive failed: out of sequence response") + return + } + result := GetTraceTimeToLiveResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Get the data ttl. This is the number of seconds we keep the data around before deleting it. +func (p *ZipkinQueryClient) GetDataTimeToLive() (r int32, err error) { + if err = p.sendGetDataTimeToLive(); err != nil { + return + } + return p.recvGetDataTimeToLive() +} + +func (p *ZipkinQueryClient) sendGetDataTimeToLive() (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getDataTimeToLive", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetDataTimeToLiveArgs{} + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetDataTimeToLive() (value int32, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error36 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error37 error + error37, err = error36.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error37 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getDataTimeToLive failed: out of sequence response") + return + } + result := GetDataTimeToLiveResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Get an aggregate representation of all services paired with every service they call in to. +// This includes information on call counts and mean/stdDev/etc of call durations. The two arguments +// specify epoch time in microseconds. The end time is optional and defaults to one day after the +// start time. +// +// Parameters: +// - StartTime +// - EndTime +func (p *ZipkinQueryClient) GetDependencies(start_time int64, end_time int64) (r *zipkindependencies.Dependencies, err error) { + if err = p.sendGetDependencies(start_time, end_time); err != nil { + return + } + return p.recvGetDependencies() +} + +func (p *ZipkinQueryClient) sendGetDependencies(start_time int64, end_time int64) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getDependencies", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetDependenciesArgs{ + StartTime: start_time, + EndTime: end_time, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetDependencies() (value *zipkindependencies.Dependencies, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error38 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error39 error + error39, err = error38.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error39 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getDependencies failed: out of sequence response") + return + } + result := GetDependenciesResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Parameters: +// - ServiceName +func (p *ZipkinQueryClient) GetTopAnnotations(service_name string) (r []string, err error) { + if err = p.sendGetTopAnnotations(service_name); err != nil { + return + } + return p.recvGetTopAnnotations() +} + +func (p *ZipkinQueryClient) sendGetTopAnnotations(service_name string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTopAnnotations", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTopAnnotationsArgs{ + ServiceName: service_name, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTopAnnotations() (value []string, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error40 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error41 error + error41, err = error40.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error41 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTopAnnotations failed: out of sequence response") + return + } + result := GetTopAnnotationsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Parameters: +// - ServiceName +func (p *ZipkinQueryClient) GetTopKeyValueAnnotations(service_name string) (r []string, err error) { + if err = p.sendGetTopKeyValueAnnotations(service_name); err != nil { + return + } + return p.recvGetTopKeyValueAnnotations() +} + +func (p *ZipkinQueryClient) sendGetTopKeyValueAnnotations(service_name string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getTopKeyValueAnnotations", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetTopKeyValueAnnotationsArgs{ + ServiceName: service_name, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetTopKeyValueAnnotations() (value []string, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error42 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error43 error + error43, err = error42.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error43 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTopKeyValueAnnotations failed: out of sequence response") + return + } + result := GetTopKeyValueAnnotationsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + if result.Qe != nil { + err = result.Qe + return + } + value = result.GetSuccess() + return +} + +// Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired +// with the lists of every span duration (list) from the server to client. The lists of span durations +// include information on call counts and mean/stdDev/etc of call durations. +// +// The three arguments specify epoch time in microseconds, server side service name and rpc name. The return maps +// contains the key - client_service_name and value - list. +// +// Parameters: +// - TimeStamp +// - ServiceName +// - RpcName +func (p *ZipkinQueryClient) GetSpanDurations(time_stamp int64, service_name string, rpc_name string) (r map[string][]int64, err error) { + if err = p.sendGetSpanDurations(time_stamp, service_name, rpc_name); err != nil { + return + } + return p.recvGetSpanDurations() +} + +func (p *ZipkinQueryClient) sendGetSpanDurations(time_stamp int64, service_name string, rpc_name string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getSpanDurations", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetSpanDurationsArgs{ + TimeStamp: time_stamp, + ServiceName: service_name, + RpcName: rpc_name, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetSpanDurations() (value map[string][]int64, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error44 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error45 error + error45, err = error44.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error45 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getSpanDurations failed: out of sequence response") + return + } + result := GetSpanDurationsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + value = result.GetSuccess() + return +} + +// Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired +// with the lists of every trace Ids (list) from the server to client. +// +// The three arguments specify epoch time in microseconds, server side service name and rpc name. The return maps +// contains the key - client_service_name and value - list. +// +// Parameters: +// - TimeStamp +// - ServiceName +// - RpcName +func (p *ZipkinQueryClient) GetServiceNamesToTraceIds(time_stamp int64, service_name string, rpc_name string) (r map[string][]int64, err error) { + if err = p.sendGetServiceNamesToTraceIds(time_stamp, service_name, rpc_name); err != nil { + return + } + return p.recvGetServiceNamesToTraceIds() +} + +func (p *ZipkinQueryClient) sendGetServiceNamesToTraceIds(time_stamp int64, service_name string, rpc_name string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("getServiceNamesToTraceIds", thrift.CALL, p.SeqId); err != nil { + return + } + args := GetServiceNamesToTraceIdsArgs{ + TimeStamp: time_stamp, + ServiceName: service_name, + RpcName: rpc_name, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *ZipkinQueryClient) recvGetServiceNamesToTraceIds() (value map[string][]int64, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + _, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if mTypeId == thrift.EXCEPTION { + error46 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error47 error + error47, err = error46.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error47 + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getServiceNamesToTraceIds failed: out of sequence response") + return + } + result := GetServiceNamesToTraceIdsResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + value = result.GetSuccess() + return +} + +type ZipkinQueryProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler ZipkinQuery +} + +func (p *ZipkinQueryProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *ZipkinQueryProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *ZipkinQueryProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewZipkinQueryProcessor(handler ZipkinQuery) *ZipkinQueryProcessor { + + self48 := &ZipkinQueryProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self48.processorMap["getTraceIds"] = &zipkinQueryProcessorGetTraceIds{handler: handler} + self48.processorMap["getTraceIdsBySpanName"] = &zipkinQueryProcessorGetTraceIdsBySpanName{handler: handler} + self48.processorMap["getTraceIdsByServiceName"] = &zipkinQueryProcessorGetTraceIdsByServiceName{handler: handler} + self48.processorMap["getTraceIdsByAnnotation"] = &zipkinQueryProcessorGetTraceIdsByAnnotation{handler: handler} + self48.processorMap["tracesExist"] = &zipkinQueryProcessorTracesExist{handler: handler} + self48.processorMap["getTracesByIds"] = &zipkinQueryProcessorGetTracesByIds{handler: handler} + self48.processorMap["getTraceTimelinesByIds"] = &zipkinQueryProcessorGetTraceTimelinesByIds{handler: handler} + self48.processorMap["getTraceSummariesByIds"] = &zipkinQueryProcessorGetTraceSummariesByIds{handler: handler} + self48.processorMap["getTraceCombosByIds"] = &zipkinQueryProcessorGetTraceCombosByIds{handler: handler} + self48.processorMap["getServiceNames"] = &zipkinQueryProcessorGetServiceNames{handler: handler} + self48.processorMap["getSpanNames"] = &zipkinQueryProcessorGetSpanNames{handler: handler} + self48.processorMap["setTraceTimeToLive"] = &zipkinQueryProcessorSetTraceTimeToLive{handler: handler} + self48.processorMap["getTraceTimeToLive"] = &zipkinQueryProcessorGetTraceTimeToLive{handler: handler} + self48.processorMap["getDataTimeToLive"] = &zipkinQueryProcessorGetDataTimeToLive{handler: handler} + self48.processorMap["getDependencies"] = &zipkinQueryProcessorGetDependencies{handler: handler} + self48.processorMap["getTopAnnotations"] = &zipkinQueryProcessorGetTopAnnotations{handler: handler} + self48.processorMap["getTopKeyValueAnnotations"] = &zipkinQueryProcessorGetTopKeyValueAnnotations{handler: handler} + self48.processorMap["getSpanDurations"] = &zipkinQueryProcessorGetSpanDurations{handler: handler} + self48.processorMap["getServiceNamesToTraceIds"] = &zipkinQueryProcessorGetServiceNamesToTraceIds{handler: handler} + return self48 +} + +func (p *ZipkinQueryProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x49 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x49.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, x49 + +} + +type zipkinQueryProcessorGetTraceIds struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceIds) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceIdsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceIdsResult{} + var retval *QueryResponse + var err2 error + if retval, err2 = p.handler.GetTraceIds(args.Request); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceIds: "+err2.Error()) + oprot.WriteMessageBegin("getTraceIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTraceIds", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTraceIdsBySpanName struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceIdsBySpanName) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceIdsBySpanNameArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceIdsBySpanName", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceIdsBySpanNameResult{} + var retval []int64 + var err2 error + if retval, err2 = p.handler.GetTraceIdsBySpanName(args.ServiceName, args.SpanName, args.EndTs, args.Limit, args.Order); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceIdsBySpanName: "+err2.Error()) + oprot.WriteMessageBegin("getTraceIdsBySpanName", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTraceIdsBySpanName", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTraceIdsByServiceName struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceIdsByServiceName) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceIdsByServiceNameArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceIdsByServiceName", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceIdsByServiceNameResult{} + var retval []int64 + var err2 error + if retval, err2 = p.handler.GetTraceIdsByServiceName(args.ServiceName, args.EndTs, args.Limit, args.Order); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceIdsByServiceName: "+err2.Error()) + oprot.WriteMessageBegin("getTraceIdsByServiceName", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTraceIdsByServiceName", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTraceIdsByAnnotation struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceIdsByAnnotation) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceIdsByAnnotationArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceIdsByAnnotation", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceIdsByAnnotationResult{} + var retval []int64 + var err2 error + if retval, err2 = p.handler.GetTraceIdsByAnnotation(args.ServiceName, args.Annotation, args.Value, args.EndTs, args.Limit, args.Order); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceIdsByAnnotation: "+err2.Error()) + oprot.WriteMessageBegin("getTraceIdsByAnnotation", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTraceIdsByAnnotation", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorTracesExist struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorTracesExist) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TracesExistArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("tracesExist", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := TracesExistResult{} + var retval map[int64]bool + var err2 error + if retval, err2 = p.handler.TracesExist(args.TraceIds); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing tracesExist: "+err2.Error()) + oprot.WriteMessageBegin("tracesExist", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("tracesExist", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTracesByIds struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTracesByIds) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTracesByIdsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTracesByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTracesByIdsResult{} + var retval []*Trace + var err2 error + if retval, err2 = p.handler.GetTracesByIds(args.TraceIds, args.Adjust); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTracesByIds: "+err2.Error()) + oprot.WriteMessageBegin("getTracesByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTracesByIds", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTraceTimelinesByIds struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceTimelinesByIds) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceTimelinesByIdsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceTimelinesByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceTimelinesByIdsResult{} + var retval []*TraceTimeline + var err2 error + if retval, err2 = p.handler.GetTraceTimelinesByIds(args.TraceIds, args.Adjust); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceTimelinesByIds: "+err2.Error()) + oprot.WriteMessageBegin("getTraceTimelinesByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTraceTimelinesByIds", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTraceSummariesByIds struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceSummariesByIds) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceSummariesByIdsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceSummariesByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceSummariesByIdsResult{} + var retval []*TraceSummary + var err2 error + if retval, err2 = p.handler.GetTraceSummariesByIds(args.TraceIds, args.Adjust); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceSummariesByIds: "+err2.Error()) + oprot.WriteMessageBegin("getTraceSummariesByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTraceSummariesByIds", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTraceCombosByIds struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceCombosByIds) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceCombosByIdsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceCombosByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceCombosByIdsResult{} + var retval []*TraceCombo + var err2 error + if retval, err2 = p.handler.GetTraceCombosByIds(args.TraceIds, args.Adjust); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceCombosByIds: "+err2.Error()) + oprot.WriteMessageBegin("getTraceCombosByIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTraceCombosByIds", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetServiceNames struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetServiceNames) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetServiceNamesArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getServiceNames", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetServiceNamesResult{} + var retval map[string]bool + var err2 error + if retval, err2 = p.handler.GetServiceNames(); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getServiceNames: "+err2.Error()) + oprot.WriteMessageBegin("getServiceNames", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getServiceNames", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetSpanNames struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetSpanNames) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetSpanNamesArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getSpanNames", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetSpanNamesResult{} + var retval map[string]bool + var err2 error + if retval, err2 = p.handler.GetSpanNames(args.ServiceName); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getSpanNames: "+err2.Error()) + oprot.WriteMessageBegin("getSpanNames", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getSpanNames", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorSetTraceTimeToLive struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorSetTraceTimeToLive) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := SetTraceTimeToLiveArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("setTraceTimeToLive", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := SetTraceTimeToLiveResult{} + var err2 error + if err2 = p.handler.SetTraceTimeToLive(args.TraceId, args.TtlSeconds); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing setTraceTimeToLive: "+err2.Error()) + oprot.WriteMessageBegin("setTraceTimeToLive", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } + if err2 = oprot.WriteMessageBegin("setTraceTimeToLive", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTraceTimeToLive struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTraceTimeToLive) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTraceTimeToLiveArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTraceTimeToLive", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTraceTimeToLiveResult{} + var retval int32 + var err2 error + if retval, err2 = p.handler.GetTraceTimeToLive(args.TraceId); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTraceTimeToLive: "+err2.Error()) + oprot.WriteMessageBegin("getTraceTimeToLive", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = &retval + } + if err2 = oprot.WriteMessageBegin("getTraceTimeToLive", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetDataTimeToLive struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetDataTimeToLive) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetDataTimeToLiveArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getDataTimeToLive", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetDataTimeToLiveResult{} + var retval int32 + var err2 error + if retval, err2 = p.handler.GetDataTimeToLive(); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getDataTimeToLive: "+err2.Error()) + oprot.WriteMessageBegin("getDataTimeToLive", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = &retval + } + if err2 = oprot.WriteMessageBegin("getDataTimeToLive", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetDependencies struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetDependencies) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetDependenciesArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getDependencies", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetDependenciesResult{} + var retval *zipkindependencies.Dependencies + var err2 error + if retval, err2 = p.handler.GetDependencies(args.StartTime, args.EndTime); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getDependencies: "+err2.Error()) + oprot.WriteMessageBegin("getDependencies", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getDependencies", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTopAnnotations struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTopAnnotations) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTopAnnotationsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTopAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTopAnnotationsResult{} + var retval []string + var err2 error + if retval, err2 = p.handler.GetTopAnnotations(args.ServiceName); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTopAnnotations: "+err2.Error()) + oprot.WriteMessageBegin("getTopAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTopAnnotations", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetTopKeyValueAnnotations struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetTopKeyValueAnnotations) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetTopKeyValueAnnotationsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getTopKeyValueAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetTopKeyValueAnnotationsResult{} + var retval []string + var err2 error + if retval, err2 = p.handler.GetTopKeyValueAnnotations(args.ServiceName); err2 != nil { + switch v := err2.(type) { + case *QueryException: + result.Qe = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTopKeyValueAnnotations: "+err2.Error()) + oprot.WriteMessageBegin("getTopKeyValueAnnotations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getTopKeyValueAnnotations", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetSpanDurations struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetSpanDurations) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetSpanDurationsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getSpanDurations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetSpanDurationsResult{} + var retval map[string][]int64 + var err2 error + if retval, err2 = p.handler.GetSpanDurations(args.TimeStamp, args.ServiceName, args.RpcName); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getSpanDurations: "+err2.Error()) + oprot.WriteMessageBegin("getSpanDurations", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getSpanDurations", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type zipkinQueryProcessorGetServiceNamesToTraceIds struct { + handler ZipkinQuery +} + +func (p *zipkinQueryProcessorGetServiceNamesToTraceIds) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := GetServiceNamesToTraceIdsArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("getServiceNamesToTraceIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := GetServiceNamesToTraceIdsResult{} + var retval map[string][]int64 + var err2 error + if retval, err2 = p.handler.GetServiceNamesToTraceIds(args.TimeStamp, args.ServiceName, args.RpcName); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getServiceNamesToTraceIds: "+err2.Error()) + oprot.WriteMessageBegin("getServiceNamesToTraceIds", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("getServiceNamesToTraceIds", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +// HELPER FUNCTIONS AND STRUCTURES + +type GetTraceIdsArgs struct { + Request *QueryRequest `thrift:"request,1" json:"request"` +} + +func NewGetTraceIdsArgs() *GetTraceIdsArgs { + return &GetTraceIdsArgs{} +} + +var GetTraceIdsArgs_Request_DEFAULT *QueryRequest + +func (p *GetTraceIdsArgs) GetRequest() *QueryRequest { + if !p.IsSetRequest() { + return GetTraceIdsArgs_Request_DEFAULT + } + return p.Request +} +func (p *GetTraceIdsArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *GetTraceIdsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsArgs) ReadField1(iprot thrift.TProtocol) error { + p.Request = &QueryRequest{} + if err := p.Request.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Request, err) + } + return nil +} + +func (p *GetTraceIdsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIds_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:request: %s", p, err) + } + if err := p.Request.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Request, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:request: %s", p, err) + } + return err +} + +func (p *GetTraceIdsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsArgs(%+v)", *p) +} + +type GetTraceIdsResult struct { + Success *QueryResponse `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceIdsResult() *GetTraceIdsResult { + return &GetTraceIdsResult{} +} + +var GetTraceIdsResult_Success_DEFAULT *QueryResponse + +func (p *GetTraceIdsResult) GetSuccess() *QueryResponse { + if !p.IsSetSuccess() { + return GetTraceIdsResult_Success_DEFAULT + } + return p.Success +} + +var GetTraceIdsResult_Qe_DEFAULT *QueryException + +func (p *GetTraceIdsResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceIdsResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceIdsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceIdsResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceIdsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = &QueryResponse{} + if err := p.Success.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Success, err) + } + return nil +} + +func (p *GetTraceIdsResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceIdsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIds_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := p.Success.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Success, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsResult(%+v)", *p) +} + +type GetTraceIdsBySpanNameArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` + SpanName string `thrift:"span_name,2" json:"span_name"` + // unused field # 3 + EndTs int64 `thrift:"end_ts,4" json:"end_ts"` + Limit int32 `thrift:"limit,5" json:"limit"` + Order Order `thrift:"order,6" json:"order"` +} + +func NewGetTraceIdsBySpanNameArgs() *GetTraceIdsBySpanNameArgs { + return &GetTraceIdsBySpanNameArgs{} +} + +func (p *GetTraceIdsBySpanNameArgs) GetServiceName() string { + return p.ServiceName +} + +func (p *GetTraceIdsBySpanNameArgs) GetSpanName() string { + return p.SpanName +} + +func (p *GetTraceIdsBySpanNameArgs) GetEndTs() int64 { + return p.EndTs +} + +func (p *GetTraceIdsBySpanNameArgs) GetLimit() int32 { + return p.Limit +} + +func (p *GetTraceIdsBySpanNameArgs) GetOrder() Order { + return p.Order +} +func (p *GetTraceIdsBySpanNameArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + case 5: + if err := p.ReadField5(iprot); err != nil { + return err + } + case 6: + if err := p.ReadField6(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsBySpanNameArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetTraceIdsBySpanNameArgs) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.SpanName = v + } + return nil +} + +func (p *GetTraceIdsBySpanNameArgs) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 4: %s", err) + } else { + p.EndTs = v + } + return nil +} + +func (p *GetTraceIdsBySpanNameArgs) ReadField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 5: %s", err) + } else { + p.Limit = v + } + return nil +} + +func (p *GetTraceIdsBySpanNameArgs) ReadField6(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 6: %s", err) + } else { + temp := Order(v) + p.Order = temp + } + return nil +} + +func (p *GetTraceIdsBySpanNameArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIdsBySpanName_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsBySpanNameArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *GetTraceIdsBySpanNameArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("span_name", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:span_name: %s", p, err) + } + if err := oprot.WriteString(string(p.SpanName)); err != nil { + return fmt.Errorf("%T.span_name (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:span_name: %s", p, err) + } + return err +} + +func (p *GetTraceIdsBySpanNameArgs) writeField4(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_ts", thrift.I64, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:end_ts: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTs)); err != nil { + return fmt.Errorf("%T.end_ts (4) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:end_ts: %s", p, err) + } + return err +} + +func (p *GetTraceIdsBySpanNameArgs) writeField5(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("limit", thrift.I32, 5); err != nil { + return fmt.Errorf("%T write field begin error 5:limit: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Limit)); err != nil { + return fmt.Errorf("%T.limit (5) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 5:limit: %s", p, err) + } + return err +} + +func (p *GetTraceIdsBySpanNameArgs) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("order", thrift.I32, 6); err != nil { + return fmt.Errorf("%T write field begin error 6:order: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Order)); err != nil { + return fmt.Errorf("%T.order (6) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 6:order: %s", p, err) + } + return err +} + +func (p *GetTraceIdsBySpanNameArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsBySpanNameArgs(%+v)", *p) +} + +type GetTraceIdsBySpanNameResult struct { + Success []int64 `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceIdsBySpanNameResult() *GetTraceIdsBySpanNameResult { + return &GetTraceIdsBySpanNameResult{} +} + +var GetTraceIdsBySpanNameResult_Success_DEFAULT []int64 + +func (p *GetTraceIdsBySpanNameResult) GetSuccess() []int64 { + return p.Success +} + +var GetTraceIdsBySpanNameResult_Qe_DEFAULT *QueryException + +func (p *GetTraceIdsBySpanNameResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceIdsBySpanNameResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceIdsBySpanNameResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceIdsBySpanNameResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceIdsBySpanNameResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsBySpanNameResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + var _elem50 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem50 = v + } + p.Success = append(p.Success, _elem50) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceIdsBySpanNameResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceIdsBySpanNameResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIdsBySpanName_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsBySpanNameResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsBySpanNameResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsBySpanNameResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsBySpanNameResult(%+v)", *p) +} + +type GetTraceIdsByServiceNameArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` + // unused field # 2 + EndTs int64 `thrift:"end_ts,3" json:"end_ts"` + Limit int32 `thrift:"limit,4" json:"limit"` + Order Order `thrift:"order,5" json:"order"` +} + +func NewGetTraceIdsByServiceNameArgs() *GetTraceIdsByServiceNameArgs { + return &GetTraceIdsByServiceNameArgs{} +} + +func (p *GetTraceIdsByServiceNameArgs) GetServiceName() string { + return p.ServiceName +} + +func (p *GetTraceIdsByServiceNameArgs) GetEndTs() int64 { + return p.EndTs +} + +func (p *GetTraceIdsByServiceNameArgs) GetLimit() int32 { + return p.Limit +} + +func (p *GetTraceIdsByServiceNameArgs) GetOrder() Order { + return p.Order +} +func (p *GetTraceIdsByServiceNameArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 4: + if err := p.ReadField4(iprot); err != nil { + return err + } + case 5: + if err := p.ReadField5(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsByServiceNameArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetTraceIdsByServiceNameArgs) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.EndTs = v + } + return nil +} + +func (p *GetTraceIdsByServiceNameArgs) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 4: %s", err) + } else { + p.Limit = v + } + return nil +} + +func (p *GetTraceIdsByServiceNameArgs) ReadField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 5: %s", err) + } else { + temp := Order(v) + p.Order = temp + } + return nil +} + +func (p *GetTraceIdsByServiceNameArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIdsByServiceName_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsByServiceNameArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByServiceNameArgs) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_ts", thrift.I64, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:end_ts: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTs)); err != nil { + return fmt.Errorf("%T.end_ts (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:end_ts: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByServiceNameArgs) writeField4(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("limit", thrift.I32, 4); err != nil { + return fmt.Errorf("%T write field begin error 4:limit: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Limit)); err != nil { + return fmt.Errorf("%T.limit (4) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 4:limit: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByServiceNameArgs) writeField5(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("order", thrift.I32, 5); err != nil { + return fmt.Errorf("%T write field begin error 5:order: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Order)); err != nil { + return fmt.Errorf("%T.order (5) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 5:order: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByServiceNameArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsByServiceNameArgs(%+v)", *p) +} + +type GetTraceIdsByServiceNameResult struct { + Success []int64 `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceIdsByServiceNameResult() *GetTraceIdsByServiceNameResult { + return &GetTraceIdsByServiceNameResult{} +} + +var GetTraceIdsByServiceNameResult_Success_DEFAULT []int64 + +func (p *GetTraceIdsByServiceNameResult) GetSuccess() []int64 { + return p.Success +} + +var GetTraceIdsByServiceNameResult_Qe_DEFAULT *QueryException + +func (p *GetTraceIdsByServiceNameResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceIdsByServiceNameResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceIdsByServiceNameResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceIdsByServiceNameResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceIdsByServiceNameResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsByServiceNameResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + var _elem51 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem51 = v + } + p.Success = append(p.Success, _elem51) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceIdsByServiceNameResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceIdsByServiceNameResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIdsByServiceName_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsByServiceNameResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsByServiceNameResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsByServiceNameResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsByServiceNameResult(%+v)", *p) +} + +type GetTraceIdsByAnnotationArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` + Annotation string `thrift:"annotation,2" json:"annotation"` + Value []byte `thrift:"value,3" json:"value"` + // unused field # 4 + EndTs int64 `thrift:"end_ts,5" json:"end_ts"` + Limit int32 `thrift:"limit,6" json:"limit"` + Order Order `thrift:"order,7" json:"order"` +} + +func NewGetTraceIdsByAnnotationArgs() *GetTraceIdsByAnnotationArgs { + return &GetTraceIdsByAnnotationArgs{} +} + +func (p *GetTraceIdsByAnnotationArgs) GetServiceName() string { + return p.ServiceName +} + +func (p *GetTraceIdsByAnnotationArgs) GetAnnotation() string { + return p.Annotation +} + +func (p *GetTraceIdsByAnnotationArgs) GetValue() []byte { + return p.Value +} + +func (p *GetTraceIdsByAnnotationArgs) GetEndTs() int64 { + return p.EndTs +} + +func (p *GetTraceIdsByAnnotationArgs) GetLimit() int32 { + return p.Limit +} + +func (p *GetTraceIdsByAnnotationArgs) GetOrder() Order { + return p.Order +} +func (p *GetTraceIdsByAnnotationArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + case 5: + if err := p.ReadField5(iprot); err != nil { + return err + } + case 6: + if err := p.ReadField6(iprot); err != nil { + return err + } + case 7: + if err := p.ReadField7(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.Annotation = v + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadBinary(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.Value = v + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) ReadField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 5: %s", err) + } else { + p.EndTs = v + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) ReadField6(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 6: %s", err) + } else { + p.Limit = v + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) ReadField7(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 7: %s", err) + } else { + temp := Order(v) + p.Order = temp + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIdsByAnnotation_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField7(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsByAnnotationArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByAnnotationArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("annotation", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:annotation: %s", p, err) + } + if err := oprot.WriteString(string(p.Annotation)); err != nil { + return fmt.Errorf("%T.annotation (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:annotation: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByAnnotationArgs) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("value", thrift.STRING, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:value: %s", p, err) + } + if err := oprot.WriteBinary(p.Value); err != nil { + return fmt.Errorf("%T.value (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:value: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByAnnotationArgs) writeField5(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_ts", thrift.I64, 5); err != nil { + return fmt.Errorf("%T write field begin error 5:end_ts: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTs)); err != nil { + return fmt.Errorf("%T.end_ts (5) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 5:end_ts: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByAnnotationArgs) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("limit", thrift.I32, 6); err != nil { + return fmt.Errorf("%T write field begin error 6:limit: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Limit)); err != nil { + return fmt.Errorf("%T.limit (6) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 6:limit: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByAnnotationArgs) writeField7(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("order", thrift.I32, 7); err != nil { + return fmt.Errorf("%T write field begin error 7:order: %s", p, err) + } + if err := oprot.WriteI32(int32(p.Order)); err != nil { + return fmt.Errorf("%T.order (7) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 7:order: %s", p, err) + } + return err +} + +func (p *GetTraceIdsByAnnotationArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsByAnnotationArgs(%+v)", *p) +} + +type GetTraceIdsByAnnotationResult struct { + Success []int64 `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceIdsByAnnotationResult() *GetTraceIdsByAnnotationResult { + return &GetTraceIdsByAnnotationResult{} +} + +var GetTraceIdsByAnnotationResult_Success_DEFAULT []int64 + +func (p *GetTraceIdsByAnnotationResult) GetSuccess() []int64 { + return p.Success +} + +var GetTraceIdsByAnnotationResult_Qe_DEFAULT *QueryException + +func (p *GetTraceIdsByAnnotationResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceIdsByAnnotationResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceIdsByAnnotationResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceIdsByAnnotationResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceIdsByAnnotationResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceIdsByAnnotationResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + var _elem52 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem52 = v + } + p.Success = append(p.Success, _elem52) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceIdsByAnnotationResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceIdsByAnnotationResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceIdsByAnnotation_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceIdsByAnnotationResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsByAnnotationResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceIdsByAnnotationResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceIdsByAnnotationResult(%+v)", *p) +} + +type TracesExistArgs struct { + TraceIds []int64 `thrift:"trace_ids,1" json:"trace_ids"` +} + +func NewTracesExistArgs() *TracesExistArgs { + return &TracesExistArgs{} +} + +func (p *TracesExistArgs) GetTraceIds() []int64 { + return p.TraceIds +} +func (p *TracesExistArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *TracesExistArgs) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.TraceIds = tSlice + for i := 0; i < size; i++ { + var _elem53 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem53 = v + } + p.TraceIds = append(p.TraceIds, _elem53) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *TracesExistArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("tracesExist_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *TracesExistArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_ids", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_ids: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.TraceIds)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.TraceIds { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_ids: %s", p, err) + } + return err +} + +func (p *TracesExistArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TracesExistArgs(%+v)", *p) +} + +type TracesExistResult struct { + Success map[int64]bool `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewTracesExistResult() *TracesExistResult { + return &TracesExistResult{} +} + +var TracesExistResult_Success_DEFAULT map[int64]bool + +func (p *TracesExistResult) GetSuccess() map[int64]bool { + return p.Success +} + +var TracesExistResult_Qe_DEFAULT *QueryException + +func (p *TracesExistResult) GetQe() *QueryException { + if !p.IsSetQe() { + return TracesExistResult_Qe_DEFAULT + } + return p.Qe +} +func (p *TracesExistResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TracesExistResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *TracesExistResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *TracesExistResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin() + if err != nil { + return fmt.Errorf("error reading set begin: %s", err) + } + tSet := make(map[int64]bool, size) + p.Success = tSet + for i := 0; i < size; i++ { + var _elem54 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem54 = v + } + p.Success[_elem54] = true + } + if err := iprot.ReadSetEnd(); err != nil { + return fmt.Errorf("error reading set end: %s", err) + } + return nil +} + +func (p *TracesExistResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *TracesExistResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("tracesExist_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *TracesExistResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.SET, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteSetBegin(thrift.I64, len(p.Success)); err != nil { + return fmt.Errorf("error writing set begin: %s", err) + } + for v, _ := range p.Success { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteSetEnd(); err != nil { + return fmt.Errorf("error writing set end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *TracesExistResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *TracesExistResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TracesExistResult(%+v)", *p) +} + +type GetTracesByIdsArgs struct { + TraceIds []int64 `thrift:"trace_ids,1" json:"trace_ids"` + Adjust []Adjust `thrift:"adjust,2" json:"adjust"` +} + +func NewGetTracesByIdsArgs() *GetTracesByIdsArgs { + return &GetTracesByIdsArgs{} +} + +func (p *GetTracesByIdsArgs) GetTraceIds() []int64 { + return p.TraceIds +} + +func (p *GetTracesByIdsArgs) GetAdjust() []Adjust { + return p.Adjust +} +func (p *GetTracesByIdsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTracesByIdsArgs) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.TraceIds = tSlice + for i := 0; i < size; i++ { + var _elem55 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem55 = v + } + p.TraceIds = append(p.TraceIds, _elem55) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTracesByIdsArgs) ReadField2(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]Adjust, 0, size) + p.Adjust = tSlice + for i := 0; i < size; i++ { + var _elem56 Adjust + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + temp := Adjust(v) + _elem56 = temp + } + p.Adjust = append(p.Adjust, _elem56) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTracesByIdsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTracesByIds_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTracesByIdsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_ids", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_ids: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.TraceIds)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.TraceIds { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_ids: %s", p, err) + } + return err +} + +func (p *GetTracesByIdsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("adjust", thrift.LIST, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:adjust: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I32, len(p.Adjust)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Adjust { + if err := oprot.WriteI32(int32(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:adjust: %s", p, err) + } + return err +} + +func (p *GetTracesByIdsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTracesByIdsArgs(%+v)", *p) +} + +type GetTracesByIdsResult struct { + Success []*Trace `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTracesByIdsResult() *GetTracesByIdsResult { + return &GetTracesByIdsResult{} +} + +var GetTracesByIdsResult_Success_DEFAULT []*Trace + +func (p *GetTracesByIdsResult) GetSuccess() []*Trace { + return p.Success +} + +var GetTracesByIdsResult_Qe_DEFAULT *QueryException + +func (p *GetTracesByIdsResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTracesByIdsResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTracesByIdsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTracesByIdsResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTracesByIdsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTracesByIdsResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*Trace, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + _elem57 := &Trace{} + if err := _elem57.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem57, err) + } + p.Success = append(p.Success, _elem57) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTracesByIdsResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTracesByIdsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTracesByIds_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTracesByIdsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTracesByIdsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTracesByIdsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTracesByIdsResult(%+v)", *p) +} + +type GetTraceTimelinesByIdsArgs struct { + TraceIds []int64 `thrift:"trace_ids,1" json:"trace_ids"` + Adjust []Adjust `thrift:"adjust,2" json:"adjust"` +} + +func NewGetTraceTimelinesByIdsArgs() *GetTraceTimelinesByIdsArgs { + return &GetTraceTimelinesByIdsArgs{} +} + +func (p *GetTraceTimelinesByIdsArgs) GetTraceIds() []int64 { + return p.TraceIds +} + +func (p *GetTraceTimelinesByIdsArgs) GetAdjust() []Adjust { + return p.Adjust +} +func (p *GetTraceTimelinesByIdsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsArgs) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.TraceIds = tSlice + for i := 0; i < size; i++ { + var _elem58 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem58 = v + } + p.TraceIds = append(p.TraceIds, _elem58) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsArgs) ReadField2(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]Adjust, 0, size) + p.Adjust = tSlice + for i := 0; i < size; i++ { + var _elem59 Adjust + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + temp := Adjust(v) + _elem59 = temp + } + p.Adjust = append(p.Adjust, _elem59) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceTimelinesByIds_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_ids", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_ids: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.TraceIds)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.TraceIds { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_ids: %s", p, err) + } + return err +} + +func (p *GetTraceTimelinesByIdsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("adjust", thrift.LIST, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:adjust: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I32, len(p.Adjust)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Adjust { + if err := oprot.WriteI32(int32(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:adjust: %s", p, err) + } + return err +} + +func (p *GetTraceTimelinesByIdsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceTimelinesByIdsArgs(%+v)", *p) +} + +type GetTraceTimelinesByIdsResult struct { + Success []*TraceTimeline `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceTimelinesByIdsResult() *GetTraceTimelinesByIdsResult { + return &GetTraceTimelinesByIdsResult{} +} + +var GetTraceTimelinesByIdsResult_Success_DEFAULT []*TraceTimeline + +func (p *GetTraceTimelinesByIdsResult) GetSuccess() []*TraceTimeline { + return p.Success +} + +var GetTraceTimelinesByIdsResult_Qe_DEFAULT *QueryException + +func (p *GetTraceTimelinesByIdsResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceTimelinesByIdsResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceTimelinesByIdsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceTimelinesByIdsResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceTimelinesByIdsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*TraceTimeline, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + _elem60 := &TraceTimeline{} + if err := _elem60.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem60, err) + } + p.Success = append(p.Success, _elem60) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceTimelinesByIds_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceTimelinesByIdsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceTimelinesByIdsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceTimelinesByIdsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceTimelinesByIdsResult(%+v)", *p) +} + +type GetTraceSummariesByIdsArgs struct { + TraceIds []int64 `thrift:"trace_ids,1" json:"trace_ids"` + Adjust []Adjust `thrift:"adjust,2" json:"adjust"` +} + +func NewGetTraceSummariesByIdsArgs() *GetTraceSummariesByIdsArgs { + return &GetTraceSummariesByIdsArgs{} +} + +func (p *GetTraceSummariesByIdsArgs) GetTraceIds() []int64 { + return p.TraceIds +} + +func (p *GetTraceSummariesByIdsArgs) GetAdjust() []Adjust { + return p.Adjust +} +func (p *GetTraceSummariesByIdsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceSummariesByIdsArgs) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.TraceIds = tSlice + for i := 0; i < size; i++ { + var _elem61 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem61 = v + } + p.TraceIds = append(p.TraceIds, _elem61) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceSummariesByIdsArgs) ReadField2(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]Adjust, 0, size) + p.Adjust = tSlice + for i := 0; i < size; i++ { + var _elem62 Adjust + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + temp := Adjust(v) + _elem62 = temp + } + p.Adjust = append(p.Adjust, _elem62) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceSummariesByIdsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceSummariesByIds_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceSummariesByIdsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_ids", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_ids: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.TraceIds)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.TraceIds { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_ids: %s", p, err) + } + return err +} + +func (p *GetTraceSummariesByIdsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("adjust", thrift.LIST, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:adjust: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I32, len(p.Adjust)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Adjust { + if err := oprot.WriteI32(int32(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:adjust: %s", p, err) + } + return err +} + +func (p *GetTraceSummariesByIdsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceSummariesByIdsArgs(%+v)", *p) +} + +type GetTraceSummariesByIdsResult struct { + Success []*TraceSummary `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceSummariesByIdsResult() *GetTraceSummariesByIdsResult { + return &GetTraceSummariesByIdsResult{} +} + +var GetTraceSummariesByIdsResult_Success_DEFAULT []*TraceSummary + +func (p *GetTraceSummariesByIdsResult) GetSuccess() []*TraceSummary { + return p.Success +} + +var GetTraceSummariesByIdsResult_Qe_DEFAULT *QueryException + +func (p *GetTraceSummariesByIdsResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceSummariesByIdsResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceSummariesByIdsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceSummariesByIdsResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceSummariesByIdsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceSummariesByIdsResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*TraceSummary, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + _elem63 := &TraceSummary{} + if err := _elem63.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem63, err) + } + p.Success = append(p.Success, _elem63) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceSummariesByIdsResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceSummariesByIdsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceSummariesByIds_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceSummariesByIdsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceSummariesByIdsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceSummariesByIdsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceSummariesByIdsResult(%+v)", *p) +} + +type GetTraceCombosByIdsArgs struct { + TraceIds []int64 `thrift:"trace_ids,1" json:"trace_ids"` + Adjust []Adjust `thrift:"adjust,2" json:"adjust"` +} + +func NewGetTraceCombosByIdsArgs() *GetTraceCombosByIdsArgs { + return &GetTraceCombosByIdsArgs{} +} + +func (p *GetTraceCombosByIdsArgs) GetTraceIds() []int64 { + return p.TraceIds +} + +func (p *GetTraceCombosByIdsArgs) GetAdjust() []Adjust { + return p.Adjust +} +func (p *GetTraceCombosByIdsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceCombosByIdsArgs) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + p.TraceIds = tSlice + for i := 0; i < size; i++ { + var _elem64 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem64 = v + } + p.TraceIds = append(p.TraceIds, _elem64) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceCombosByIdsArgs) ReadField2(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]Adjust, 0, size) + p.Adjust = tSlice + for i := 0; i < size; i++ { + var _elem65 Adjust + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + temp := Adjust(v) + _elem65 = temp + } + p.Adjust = append(p.Adjust, _elem65) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceCombosByIdsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceCombosByIds_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceCombosByIdsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_ids", thrift.LIST, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_ids: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(p.TraceIds)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.TraceIds { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_ids: %s", p, err) + } + return err +} + +func (p *GetTraceCombosByIdsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("adjust", thrift.LIST, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:adjust: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I32, len(p.Adjust)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Adjust { + if err := oprot.WriteI32(int32(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:adjust: %s", p, err) + } + return err +} + +func (p *GetTraceCombosByIdsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceCombosByIdsArgs(%+v)", *p) +} + +type GetTraceCombosByIdsResult struct { + Success []*TraceCombo `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceCombosByIdsResult() *GetTraceCombosByIdsResult { + return &GetTraceCombosByIdsResult{} +} + +var GetTraceCombosByIdsResult_Success_DEFAULT []*TraceCombo + +func (p *GetTraceCombosByIdsResult) GetSuccess() []*TraceCombo { + return p.Success +} + +var GetTraceCombosByIdsResult_Qe_DEFAULT *QueryException + +func (p *GetTraceCombosByIdsResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceCombosByIdsResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceCombosByIdsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceCombosByIdsResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceCombosByIdsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceCombosByIdsResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]*TraceCombo, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + _elem66 := &TraceCombo{} + if err := _elem66.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", _elem66, err) + } + p.Success = append(p.Success, _elem66) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTraceCombosByIdsResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceCombosByIdsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceCombosByIds_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceCombosByIdsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := v.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", v, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceCombosByIdsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceCombosByIdsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceCombosByIdsResult(%+v)", *p) +} + +type GetServiceNamesArgs struct { +} + +func NewGetServiceNamesArgs() *GetServiceNamesArgs { + return &GetServiceNamesArgs{} +} + +func (p *GetServiceNamesArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetServiceNamesArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getServiceNames_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetServiceNamesArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetServiceNamesArgs(%+v)", *p) +} + +type GetServiceNamesResult struct { + Success map[string]bool `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetServiceNamesResult() *GetServiceNamesResult { + return &GetServiceNamesResult{} +} + +var GetServiceNamesResult_Success_DEFAULT map[string]bool + +func (p *GetServiceNamesResult) GetSuccess() map[string]bool { + return p.Success +} + +var GetServiceNamesResult_Qe_DEFAULT *QueryException + +func (p *GetServiceNamesResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetServiceNamesResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetServiceNamesResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetServiceNamesResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetServiceNamesResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetServiceNamesResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin() + if err != nil { + return fmt.Errorf("error reading set begin: %s", err) + } + tSet := make(map[string]bool, size) + p.Success = tSet + for i := 0; i < size; i++ { + var _elem67 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem67 = v + } + p.Success[_elem67] = true + } + if err := iprot.ReadSetEnd(); err != nil { + return fmt.Errorf("error reading set end: %s", err) + } + return nil +} + +func (p *GetServiceNamesResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetServiceNamesResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getServiceNames_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetServiceNamesResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.SET, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteSetBegin(thrift.STRING, len(p.Success)); err != nil { + return fmt.Errorf("error writing set begin: %s", err) + } + for v, _ := range p.Success { + if err := oprot.WriteString(string(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteSetEnd(); err != nil { + return fmt.Errorf("error writing set end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetServiceNamesResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetServiceNamesResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetServiceNamesResult(%+v)", *p) +} + +type GetSpanNamesArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` +} + +func NewGetSpanNamesArgs() *GetSpanNamesArgs { + return &GetSpanNamesArgs{} +} + +func (p *GetSpanNamesArgs) GetServiceName() string { + return p.ServiceName +} +func (p *GetSpanNamesArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetSpanNamesArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetSpanNamesArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getSpanNames_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetSpanNamesArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *GetSpanNamesArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetSpanNamesArgs(%+v)", *p) +} + +type GetSpanNamesResult struct { + Success map[string]bool `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetSpanNamesResult() *GetSpanNamesResult { + return &GetSpanNamesResult{} +} + +var GetSpanNamesResult_Success_DEFAULT map[string]bool + +func (p *GetSpanNamesResult) GetSuccess() map[string]bool { + return p.Success +} + +var GetSpanNamesResult_Qe_DEFAULT *QueryException + +func (p *GetSpanNamesResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetSpanNamesResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetSpanNamesResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetSpanNamesResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetSpanNamesResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetSpanNamesResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin() + if err != nil { + return fmt.Errorf("error reading set begin: %s", err) + } + tSet := make(map[string]bool, size) + p.Success = tSet + for i := 0; i < size; i++ { + var _elem68 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem68 = v + } + p.Success[_elem68] = true + } + if err := iprot.ReadSetEnd(); err != nil { + return fmt.Errorf("error reading set end: %s", err) + } + return nil +} + +func (p *GetSpanNamesResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetSpanNamesResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getSpanNames_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetSpanNamesResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.SET, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteSetBegin(thrift.STRING, len(p.Success)); err != nil { + return fmt.Errorf("error writing set begin: %s", err) + } + for v, _ := range p.Success { + if err := oprot.WriteString(string(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteSetEnd(); err != nil { + return fmt.Errorf("error writing set end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetSpanNamesResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetSpanNamesResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetSpanNamesResult(%+v)", *p) +} + +type SetTraceTimeToLiveArgs struct { + TraceId int64 `thrift:"trace_id,1" json:"trace_id"` + TtlSeconds int32 `thrift:"ttl_seconds,2" json:"ttl_seconds"` +} + +func NewSetTraceTimeToLiveArgs() *SetTraceTimeToLiveArgs { + return &SetTraceTimeToLiveArgs{} +} + +func (p *SetTraceTimeToLiveArgs) GetTraceId() int64 { + return p.TraceId +} + +func (p *SetTraceTimeToLiveArgs) GetTtlSeconds() int32 { + return p.TtlSeconds +} +func (p *SetTraceTimeToLiveArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *SetTraceTimeToLiveArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.TraceId = v + } + return nil +} + +func (p *SetTraceTimeToLiveArgs) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.TtlSeconds = v + } + return nil +} + +func (p *SetTraceTimeToLiveArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("setTraceTimeToLive_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *SetTraceTimeToLiveArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_id", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.TraceId)); err != nil { + return fmt.Errorf("%T.trace_id (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_id: %s", p, err) + } + return err +} + +func (p *SetTraceTimeToLiveArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("ttl_seconds", thrift.I32, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:ttl_seconds: %s", p, err) + } + if err := oprot.WriteI32(int32(p.TtlSeconds)); err != nil { + return fmt.Errorf("%T.ttl_seconds (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:ttl_seconds: %s", p, err) + } + return err +} + +func (p *SetTraceTimeToLiveArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SetTraceTimeToLiveArgs(%+v)", *p) +} + +type SetTraceTimeToLiveResult struct { + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewSetTraceTimeToLiveResult() *SetTraceTimeToLiveResult { + return &SetTraceTimeToLiveResult{} +} + +var SetTraceTimeToLiveResult_Qe_DEFAULT *QueryException + +func (p *SetTraceTimeToLiveResult) GetQe() *QueryException { + if !p.IsSetQe() { + return SetTraceTimeToLiveResult_Qe_DEFAULT + } + return p.Qe +} +func (p *SetTraceTimeToLiveResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *SetTraceTimeToLiveResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *SetTraceTimeToLiveResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *SetTraceTimeToLiveResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("setTraceTimeToLive_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *SetTraceTimeToLiveResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *SetTraceTimeToLiveResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SetTraceTimeToLiveResult(%+v)", *p) +} + +type GetTraceTimeToLiveArgs struct { + TraceId int64 `thrift:"trace_id,1" json:"trace_id"` +} + +func NewGetTraceTimeToLiveArgs() *GetTraceTimeToLiveArgs { + return &GetTraceTimeToLiveArgs{} +} + +func (p *GetTraceTimeToLiveArgs) GetTraceId() int64 { + return p.TraceId +} +func (p *GetTraceTimeToLiveArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceTimeToLiveArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.TraceId = v + } + return nil +} + +func (p *GetTraceTimeToLiveArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceTimeToLive_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceTimeToLiveArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("trace_id", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:trace_id: %s", p, err) + } + if err := oprot.WriteI64(int64(p.TraceId)); err != nil { + return fmt.Errorf("%T.trace_id (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:trace_id: %s", p, err) + } + return err +} + +func (p *GetTraceTimeToLiveArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceTimeToLiveArgs(%+v)", *p) +} + +type GetTraceTimeToLiveResult struct { + Success *int32 `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTraceTimeToLiveResult() *GetTraceTimeToLiveResult { + return &GetTraceTimeToLiveResult{} +} + +var GetTraceTimeToLiveResult_Success_DEFAULT int32 + +func (p *GetTraceTimeToLiveResult) GetSuccess() int32 { + if !p.IsSetSuccess() { + return GetTraceTimeToLiveResult_Success_DEFAULT + } + return *p.Success +} + +var GetTraceTimeToLiveResult_Qe_DEFAULT *QueryException + +func (p *GetTraceTimeToLiveResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTraceTimeToLiveResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTraceTimeToLiveResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTraceTimeToLiveResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTraceTimeToLiveResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTraceTimeToLiveResult) ReadField0(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + p.Success = &v + } + return nil +} + +func (p *GetTraceTimeToLiveResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTraceTimeToLiveResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTraceTimeToLive_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTraceTimeToLiveResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteI32(int32(*p.Success)); err != nil { + return fmt.Errorf("%T.success (0) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTraceTimeToLiveResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTraceTimeToLiveResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTraceTimeToLiveResult(%+v)", *p) +} + +type GetDataTimeToLiveArgs struct { +} + +func NewGetDataTimeToLiveArgs() *GetDataTimeToLiveArgs { + return &GetDataTimeToLiveArgs{} +} + +func (p *GetDataTimeToLiveArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetDataTimeToLiveArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getDataTimeToLive_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetDataTimeToLiveArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetDataTimeToLiveArgs(%+v)", *p) +} + +type GetDataTimeToLiveResult struct { + Success *int32 `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetDataTimeToLiveResult() *GetDataTimeToLiveResult { + return &GetDataTimeToLiveResult{} +} + +var GetDataTimeToLiveResult_Success_DEFAULT int32 + +func (p *GetDataTimeToLiveResult) GetSuccess() int32 { + if !p.IsSetSuccess() { + return GetDataTimeToLiveResult_Success_DEFAULT + } + return *p.Success +} + +var GetDataTimeToLiveResult_Qe_DEFAULT *QueryException + +func (p *GetDataTimeToLiveResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetDataTimeToLiveResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetDataTimeToLiveResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetDataTimeToLiveResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetDataTimeToLiveResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetDataTimeToLiveResult) ReadField0(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + p.Success = &v + } + return nil +} + +func (p *GetDataTimeToLiveResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetDataTimeToLiveResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getDataTimeToLive_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetDataTimeToLiveResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.I32, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteI32(int32(*p.Success)); err != nil { + return fmt.Errorf("%T.success (0) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetDataTimeToLiveResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetDataTimeToLiveResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetDataTimeToLiveResult(%+v)", *p) +} + +type GetDependenciesArgs struct { + StartTime int64 `thrift:"start_time,1" json:"start_time"` + EndTime int64 `thrift:"end_time,2" json:"end_time"` +} + +func NewGetDependenciesArgs() *GetDependenciesArgs { + return &GetDependenciesArgs{} +} + +func (p *GetDependenciesArgs) GetStartTime() int64 { + return p.StartTime +} + +func (p *GetDependenciesArgs) GetEndTime() int64 { + return p.EndTime +} +func (p *GetDependenciesArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetDependenciesArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.StartTime = v + } + return nil +} + +func (p *GetDependenciesArgs) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.EndTime = v + } + return nil +} + +func (p *GetDependenciesArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getDependencies_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetDependenciesArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("start_time", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:start_time: %s", p, err) + } + if err := oprot.WriteI64(int64(p.StartTime)); err != nil { + return fmt.Errorf("%T.start_time (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:start_time: %s", p, err) + } + return err +} + +func (p *GetDependenciesArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("end_time", thrift.I64, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:end_time: %s", p, err) + } + if err := oprot.WriteI64(int64(p.EndTime)); err != nil { + return fmt.Errorf("%T.end_time (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:end_time: %s", p, err) + } + return err +} + +func (p *GetDependenciesArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetDependenciesArgs(%+v)", *p) +} + +type GetDependenciesResult struct { + Success *zipkindependencies.Dependencies `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetDependenciesResult() *GetDependenciesResult { + return &GetDependenciesResult{} +} + +var GetDependenciesResult_Success_DEFAULT *zipkindependencies.Dependencies + +func (p *GetDependenciesResult) GetSuccess() *zipkindependencies.Dependencies { + if !p.IsSetSuccess() { + return GetDependenciesResult_Success_DEFAULT + } + return p.Success +} + +var GetDependenciesResult_Qe_DEFAULT *QueryException + +func (p *GetDependenciesResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetDependenciesResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetDependenciesResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetDependenciesResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetDependenciesResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetDependenciesResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = &zipkindependencies.Dependencies{} + if err := p.Success.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Success, err) + } + return nil +} + +func (p *GetDependenciesResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetDependenciesResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getDependencies_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetDependenciesResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := p.Success.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Success, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetDependenciesResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetDependenciesResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetDependenciesResult(%+v)", *p) +} + +type GetTopAnnotationsArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` +} + +func NewGetTopAnnotationsArgs() *GetTopAnnotationsArgs { + return &GetTopAnnotationsArgs{} +} + +func (p *GetTopAnnotationsArgs) GetServiceName() string { + return p.ServiceName +} +func (p *GetTopAnnotationsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTopAnnotationsArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetTopAnnotationsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTopAnnotations_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTopAnnotationsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *GetTopAnnotationsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTopAnnotationsArgs(%+v)", *p) +} + +type GetTopAnnotationsResult struct { + Success []string `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTopAnnotationsResult() *GetTopAnnotationsResult { + return &GetTopAnnotationsResult{} +} + +var GetTopAnnotationsResult_Success_DEFAULT []string + +func (p *GetTopAnnotationsResult) GetSuccess() []string { + return p.Success +} + +var GetTopAnnotationsResult_Qe_DEFAULT *QueryException + +func (p *GetTopAnnotationsResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTopAnnotationsResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTopAnnotationsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTopAnnotationsResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTopAnnotationsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTopAnnotationsResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]string, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + var _elem69 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem69 = v + } + p.Success = append(p.Success, _elem69) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTopAnnotationsResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTopAnnotationsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTopAnnotations_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTopAnnotationsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRING, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := oprot.WriteString(string(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTopAnnotationsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTopAnnotationsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTopAnnotationsResult(%+v)", *p) +} + +type GetTopKeyValueAnnotationsArgs struct { + ServiceName string `thrift:"service_name,1" json:"service_name"` +} + +func NewGetTopKeyValueAnnotationsArgs() *GetTopKeyValueAnnotationsArgs { + return &GetTopKeyValueAnnotationsArgs{} +} + +func (p *GetTopKeyValueAnnotationsArgs) GetServiceName() string { + return p.ServiceName +} +func (p *GetTopKeyValueAnnotationsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTopKeyValueAnnotationsArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetTopKeyValueAnnotationsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTopKeyValueAnnotations_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTopKeyValueAnnotationsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:service_name: %s", p, err) + } + return err +} + +func (p *GetTopKeyValueAnnotationsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTopKeyValueAnnotationsArgs(%+v)", *p) +} + +type GetTopKeyValueAnnotationsResult struct { + Success []string `thrift:"success,0" json:"success"` + Qe *QueryException `thrift:"qe,1" json:"qe"` +} + +func NewGetTopKeyValueAnnotationsResult() *GetTopKeyValueAnnotationsResult { + return &GetTopKeyValueAnnotationsResult{} +} + +var GetTopKeyValueAnnotationsResult_Success_DEFAULT []string + +func (p *GetTopKeyValueAnnotationsResult) GetSuccess() []string { + return p.Success +} + +var GetTopKeyValueAnnotationsResult_Qe_DEFAULT *QueryException + +func (p *GetTopKeyValueAnnotationsResult) GetQe() *QueryException { + if !p.IsSetQe() { + return GetTopKeyValueAnnotationsResult_Qe_DEFAULT + } + return p.Qe +} +func (p *GetTopKeyValueAnnotationsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetTopKeyValueAnnotationsResult) IsSetQe() bool { + return p.Qe != nil +} + +func (p *GetTopKeyValueAnnotationsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetTopKeyValueAnnotationsResult) ReadField0(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]string, 0, size) + p.Success = tSlice + for i := 0; i < size; i++ { + var _elem70 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem70 = v + } + p.Success = append(p.Success, _elem70) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + return nil +} + +func (p *GetTopKeyValueAnnotationsResult) ReadField1(iprot thrift.TProtocol) error { + p.Qe = &QueryException{} + if err := p.Qe.Read(iprot); err != nil { + return fmt.Errorf("%T error reading struct: %s", p.Qe, err) + } + return nil +} + +func (p *GetTopKeyValueAnnotationsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getTopKeyValueAnnotations_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetTopKeyValueAnnotationsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.STRING, len(p.Success)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range p.Success { + if err := oprot.WriteString(string(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetTopKeyValueAnnotationsResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetQe() { + if err := oprot.WriteFieldBegin("qe", thrift.STRUCT, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:qe: %s", p, err) + } + if err := p.Qe.Write(oprot); err != nil { + return fmt.Errorf("%T error writing struct: %s", p.Qe, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:qe: %s", p, err) + } + } + return err +} + +func (p *GetTopKeyValueAnnotationsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetTopKeyValueAnnotationsResult(%+v)", *p) +} + +type GetSpanDurationsArgs struct { + TimeStamp int64 `thrift:"time_stamp,1" json:"time_stamp"` + ServiceName string `thrift:"service_name,2" json:"service_name"` + RpcName string `thrift:"rpc_name,3" json:"rpc_name"` +} + +func NewGetSpanDurationsArgs() *GetSpanDurationsArgs { + return &GetSpanDurationsArgs{} +} + +func (p *GetSpanDurationsArgs) GetTimeStamp() int64 { + return p.TimeStamp +} + +func (p *GetSpanDurationsArgs) GetServiceName() string { + return p.ServiceName +} + +func (p *GetSpanDurationsArgs) GetRpcName() string { + return p.RpcName +} +func (p *GetSpanDurationsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetSpanDurationsArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.TimeStamp = v + } + return nil +} + +func (p *GetSpanDurationsArgs) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetSpanDurationsArgs) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.RpcName = v + } + return nil +} + +func (p *GetSpanDurationsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getSpanDurations_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetSpanDurationsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("time_stamp", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:time_stamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.TimeStamp)); err != nil { + return fmt.Errorf("%T.time_stamp (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:time_stamp: %s", p, err) + } + return err +} + +func (p *GetSpanDurationsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:service_name: %s", p, err) + } + return err +} + +func (p *GetSpanDurationsArgs) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("rpc_name", thrift.STRING, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:rpc_name: %s", p, err) + } + if err := oprot.WriteString(string(p.RpcName)); err != nil { + return fmt.Errorf("%T.rpc_name (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:rpc_name: %s", p, err) + } + return err +} + +func (p *GetSpanDurationsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetSpanDurationsArgs(%+v)", *p) +} + +type GetSpanDurationsResult struct { + Success map[string][]int64 `thrift:"success,0" json:"success"` +} + +func NewGetSpanDurationsResult() *GetSpanDurationsResult { + return &GetSpanDurationsResult{} +} + +var GetSpanDurationsResult_Success_DEFAULT map[string][]int64 + +func (p *GetSpanDurationsResult) GetSuccess() map[string][]int64 { + return p.Success +} +func (p *GetSpanDurationsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetSpanDurationsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetSpanDurationsResult) ReadField0(iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return fmt.Errorf("error reading map begin: %s", err) + } + tMap := make(map[string][]int64, size) + p.Success = tMap + for i := 0; i < size; i++ { + var _key71 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _key71 = v + } + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + _val72 := tSlice + for i := 0; i < size; i++ { + var _elem73 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem73 = v + } + _val72 = append(_val72, _elem73) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + p.Success[_key71] = _val72 + } + if err := iprot.ReadMapEnd(); err != nil { + return fmt.Errorf("error reading map end: %s", err) + } + return nil +} + +func (p *GetSpanDurationsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getSpanDurations_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetSpanDurationsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.MAP, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteMapBegin(thrift.STRING, thrift.LIST, len(p.Success)); err != nil { + return fmt.Errorf("error writing map begin: %s", err) + } + for k, v := range p.Success { + if err := oprot.WriteString(string(k)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(v)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range v { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + } + if err := oprot.WriteMapEnd(); err != nil { + return fmt.Errorf("error writing map end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetSpanDurationsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetSpanDurationsResult(%+v)", *p) +} + +type GetServiceNamesToTraceIdsArgs struct { + TimeStamp int64 `thrift:"time_stamp,1" json:"time_stamp"` + ServiceName string `thrift:"service_name,2" json:"service_name"` + RpcName string `thrift:"rpc_name,3" json:"rpc_name"` +} + +func NewGetServiceNamesToTraceIdsArgs() *GetServiceNamesToTraceIdsArgs { + return &GetServiceNamesToTraceIdsArgs{} +} + +func (p *GetServiceNamesToTraceIdsArgs) GetTimeStamp() int64 { + return p.TimeStamp +} + +func (p *GetServiceNamesToTraceIdsArgs) GetServiceName() string { + return p.ServiceName +} + +func (p *GetServiceNamesToTraceIdsArgs) GetRpcName() string { + return p.RpcName +} +func (p *GetServiceNamesToTraceIdsArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.ReadField1(iprot); err != nil { + return err + } + case 2: + if err := p.ReadField2(iprot); err != nil { + return err + } + case 3: + if err := p.ReadField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetServiceNamesToTraceIdsArgs) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 1: %s", err) + } else { + p.TimeStamp = v + } + return nil +} + +func (p *GetServiceNamesToTraceIdsArgs) ReadField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 2: %s", err) + } else { + p.ServiceName = v + } + return nil +} + +func (p *GetServiceNamesToTraceIdsArgs) ReadField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 3: %s", err) + } else { + p.RpcName = v + } + return nil +} + +func (p *GetServiceNamesToTraceIdsArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getServiceNamesToTraceIds_args"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetServiceNamesToTraceIdsArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("time_stamp", thrift.I64, 1); err != nil { + return fmt.Errorf("%T write field begin error 1:time_stamp: %s", p, err) + } + if err := oprot.WriteI64(int64(p.TimeStamp)); err != nil { + return fmt.Errorf("%T.time_stamp (1) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 1:time_stamp: %s", p, err) + } + return err +} + +func (p *GetServiceNamesToTraceIdsArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 2); err != nil { + return fmt.Errorf("%T write field begin error 2:service_name: %s", p, err) + } + if err := oprot.WriteString(string(p.ServiceName)); err != nil { + return fmt.Errorf("%T.service_name (2) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 2:service_name: %s", p, err) + } + return err +} + +func (p *GetServiceNamesToTraceIdsArgs) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("rpc_name", thrift.STRING, 3); err != nil { + return fmt.Errorf("%T write field begin error 3:rpc_name: %s", p, err) + } + if err := oprot.WriteString(string(p.RpcName)); err != nil { + return fmt.Errorf("%T.rpc_name (3) field write error: %s", p, err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 3:rpc_name: %s", p, err) + } + return err +} + +func (p *GetServiceNamesToTraceIdsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetServiceNamesToTraceIdsArgs(%+v)", *p) +} + +type GetServiceNamesToTraceIdsResult struct { + Success map[string][]int64 `thrift:"success,0" json:"success"` +} + +func NewGetServiceNamesToTraceIdsResult() *GetServiceNamesToTraceIdsResult { + return &GetServiceNamesToTraceIdsResult{} +} + +var GetServiceNamesToTraceIdsResult_Success_DEFAULT map[string][]int64 + +func (p *GetServiceNamesToTraceIdsResult) GetSuccess() map[string][]int64 { + return p.Success +} +func (p *GetServiceNamesToTraceIdsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *GetServiceNamesToTraceIdsResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return fmt.Errorf("%T read error: %s", p, err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return fmt.Errorf("%T field %d read error: %s", p, fieldId, err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.ReadField0(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return fmt.Errorf("%T read struct end error: %s", p, err) + } + return nil +} + +func (p *GetServiceNamesToTraceIdsResult) ReadField0(iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return fmt.Errorf("error reading map begin: %s", err) + } + tMap := make(map[string][]int64, size) + p.Success = tMap + for i := 0; i < size; i++ { + var _key74 string + if v, err := iprot.ReadString(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _key74 = v + } + _, size, err := iprot.ReadListBegin() + if err != nil { + return fmt.Errorf("error reading list begin: %s", err) + } + tSlice := make([]int64, 0, size) + _val75 := tSlice + for i := 0; i < size; i++ { + var _elem76 int64 + if v, err := iprot.ReadI64(); err != nil { + return fmt.Errorf("error reading field 0: %s", err) + } else { + _elem76 = v + } + _val75 = append(_val75, _elem76) + } + if err := iprot.ReadListEnd(); err != nil { + return fmt.Errorf("error reading list end: %s", err) + } + p.Success[_key74] = _val75 + } + if err := iprot.ReadMapEnd(); err != nil { + return fmt.Errorf("error reading map end: %s", err) + } + return nil +} + +func (p *GetServiceNamesToTraceIdsResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("getServiceNamesToTraceIds_result"); err != nil { + return fmt.Errorf("%T write struct begin error: %s", p, err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return fmt.Errorf("write field stop error: %s", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return fmt.Errorf("write struct stop error: %s", err) + } + return nil +} + +func (p *GetServiceNamesToTraceIdsResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.MAP, 0); err != nil { + return fmt.Errorf("%T write field begin error 0:success: %s", p, err) + } + if err := oprot.WriteMapBegin(thrift.STRING, thrift.LIST, len(p.Success)); err != nil { + return fmt.Errorf("error writing map begin: %s", err) + } + for k, v := range p.Success { + if err := oprot.WriteString(string(k)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + if err := oprot.WriteListBegin(thrift.I64, len(v)); err != nil { + return fmt.Errorf("error writing list begin: %s", err) + } + for _, v := range v { + if err := oprot.WriteI64(int64(v)); err != nil { + return fmt.Errorf("%T. (0) field write error: %s", p, err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return fmt.Errorf("error writing list end: %s", err) + } + } + if err := oprot.WriteMapEnd(); err != nil { + return fmt.Errorf("error writing map end: %s", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return fmt.Errorf("%T write field end error 0:success: %s", p, err) + } + } + return err +} + +func (p *GetServiceNamesToTraceIdsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetServiceNamesToTraceIdsResult(%+v)", *p) +} diff --git a/tracing/zipkin/_thrift/scribe.thrift b/tracing/zipkin/_thrift/scribe.thrift new file mode 100644 index 000000000..12e21ce1e --- /dev/null +++ b/tracing/zipkin/_thrift/scribe.thrift @@ -0,0 +1,32 @@ +# Copyright 2012 Twitter Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +namespace java com.twitter.zipkin.thriftjava +#@namespace scala com.twitter.zipkin.thriftscala + +enum ResultCode +{ + OK, + TRY_LATER +} + +struct LogEntry +{ + 1: string category, + 2: string message +} + +service Scribe +{ + ResultCode Log(1: list messages); +} diff --git a/tracing/zipkin/_thrift/zipkinCollector.thrift b/tracing/zipkin/_thrift/zipkinCollector.thrift new file mode 100644 index 000000000..aba6d9da1 --- /dev/null +++ b/tracing/zipkin/_thrift/zipkinCollector.thrift @@ -0,0 +1,35 @@ +# Copyright 2012 Twitter Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +namespace java com.twitter.zipkin.thriftjava +#@namespace scala com.twitter.zipkin.thriftscala +namespace rb Zipkin + +include "scribe.thrift" +include "zipkinDependencies.thrift" + +exception AdjustableRateException { + 1: string msg +} + +exception StoreAggregatesException { + 1: string msg +} + +service ZipkinCollector extends scribe.Scribe { + + /** Aggregates methods */ + void storeTopAnnotations(1: string service_name, 2: list annotations) throws (1: StoreAggregatesException e); + void storeTopKeyValueAnnotations(1: string service_name, 2: list annotations) throws (1: StoreAggregatesException e); + void storeDependencies(1: zipkinDependencies.Dependencies dependencies) throws (1: StoreAggregatesException e); +} diff --git a/tracing/zipkin/_thrift/zipkinCore.thrift b/tracing/zipkin/_thrift/zipkinCore.thrift new file mode 100644 index 000000000..50ea914f0 --- /dev/null +++ b/tracing/zipkin/_thrift/zipkinCore.thrift @@ -0,0 +1,59 @@ +# Copyright 2012 Twitter Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +namespace java com.twitter.zipkin.thriftjava +#@namespace scala com.twitter.zipkin.thriftscala +namespace rb Zipkin + +#************** Collection related structs ************** + +# these are the annotations we always expect to find in a span +const string CLIENT_SEND = "cs" +const string CLIENT_RECV = "cr" +const string SERVER_SEND = "ss" +const string SERVER_RECV = "sr" + +# this represents a host and port in a network +struct Endpoint { + 1: i32 ipv4, + 2: i16 port # beware that this will give us negative ports. some conversion needed + 3: string service_name # which service did this operation happen on? +} + +# some event took place, either one by the framework or by the user +struct Annotation { + 1: i64 timestamp # microseconds from epoch + 2: string value # what happened at the timestamp? + 3: optional Endpoint host # host this happened on + 4: optional i32 duration # how long did the operation take? microseconds +} + +enum AnnotationType { BOOL, BYTES, I16, I32, I64, DOUBLE, STRING } + +struct BinaryAnnotation { + 1: string key, + 2: binary value, + 3: AnnotationType annotation_type, + 4: optional Endpoint host +} + +struct Span { + 1: i64 trace_id # unique trace id, use for all spans in trace + 3: string name, # span name, rpc method for example + 4: i64 id, # unique span id, only used for this span + 5: optional i64 parent_id, # parent span id + 6: list annotations, # list of all annotations/events that occured + 8: list binary_annotations # any binary annotations + 9: optional bool debug = 0 # if true, we DEMAND that this span passes all samplers +} + diff --git a/tracing/zipkin/_thrift/zipkinDependencies.thrift b/tracing/zipkin/_thrift/zipkinDependencies.thrift new file mode 100644 index 000000000..b12cdda54 --- /dev/null +++ b/tracing/zipkin/_thrift/zipkinDependencies.thrift @@ -0,0 +1,43 @@ +# Copyright 2013 Twitter Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +namespace java com.twitter.zipkin.thriftjava +#@namespace scala com.twitter.zipkin.thriftscala +namespace rb Zipkin + +#********* Zipkin Aggregate Dependency Related Structs *********** + + +# This is a 1-to-1 translation of algebird Moments structure for holding +# count/mean/variance(stdDev)/skewness/etc about a set of values. It's +# used below to represent span time duration ranges. +struct Moments { + 1: i64 m0, # count + 2: double m1, # mean + 3: double m2, # variance * count + 4: double m3, + 5: double m4 +} + +struct DependencyLink { + 1: string parent, # parent service name (caller) + 2: string child, # child service name (callee) + 3: Moments duration_moments + # histogram? +} + +struct Dependencies { + 1: i64 start_time # microseconds from epoch + 2: i64 end_time # microseconds from epoch + 3: list links # our data +} diff --git a/tracing/zipkin/_thrift/zipkinQuery.thrift b/tracing/zipkin/_thrift/zipkinQuery.thrift new file mode 100644 index 000000000..13ede1594 --- /dev/null +++ b/tracing/zipkin/_thrift/zipkinQuery.thrift @@ -0,0 +1,252 @@ +# Copyright 2012 Twitter Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +namespace java com.twitter.zipkin.thriftjava +#@namespace scala com.twitter.zipkin.thriftscala +namespace rb Zipkin + +include "zipkinCore.thrift" +include "zipkinDependencies.thrift" + +struct Trace { + 1: list spans +} + +exception QueryException { + 1: string msg +} + +struct SpanTimestamp { + 1: string name + 2: i64 start_timestamp + 3: i64 end_timestamp +} + +/** + * This sums up a single Trace to make it easy for a client to get an overview of what happened. + */ +struct TraceSummary { + 1: i64 trace_id # the trace + 2: i64 start_timestamp # start timestamp of the trace, in microseconds + 3: i64 end_timestamp # end timestamp of the trace, in microseconds + 4: i32 duration_micro # how long did the entire trace take? in microseconds + # 5: map service_counts # which services were involved? + 6: list endpoints # which endpoints were involved? + 7: list span_timestamps +} + +/** + * A modified version of the Annotation struct that brings in more information + */ +struct TimelineAnnotation { + 1: i64 timestamp # microseconds from epoch + 2: string value # what happened at the timestamp? + 3: zipkinCore.Endpoint host # host this happened on + 4: i64 span_id # which span does this annotation belong to? + 5: optional i64 parent_id # parent span id + 6: string service_name # which service did this annotation happen on? + 7: string span_name # span name, rpc method for example +} + +/** + * This sums up a single Trace to make it easy for a client to get an overview of what happened. + */ +struct TraceTimeline { + 1: i64 trace_id # the trace + 2: i64 root_most_span_id # either the true root span or the closest we can find + 6: list annotations # annotations as they happened + 7: list binary_annotations # all the binary annotations +} + +/** + * Returns a combination of trace, summary and timeline. + */ +struct TraceCombo { + 1: Trace trace + 2: optional TraceSummary summary # not set if no spans in trace + 3: optional TraceTimeline timeline # not set if no spans in trace + 4: optional map span_depths # not set if no spans in trace +} + +enum Order { TIMESTAMP_DESC, TIMESTAMP_ASC, DURATION_ASC, DURATION_DESC, NONE } + +/** + * The raw data in our storage might have various problems. How should we adjust it before + * returning it to the user? + * + * Time skew adjuster tries to make sure that even though servers might have slightly + * different clocks the annotations in the returned data are adjusted so that they are + * in the correct order. + */ +enum Adjust { NOTHING, TIME_SKEW } + +struct QueryRequest { + 1: string service_name + 2: optional string span_name + 3: optional list annotations + 4: optional list binary_annotations + 5: i64 end_ts + 6: i32 limit + 7: Order order +} + +struct QueryResponse { + 1: list trace_ids + 2: i64 start_ts + 3: i64 end_ts +} + +service ZipkinQuery { + + #************** Index lookups ************** + + QueryResponse getTraceIds(1: QueryRequest request) throws (1: QueryException qe); + + /** + * Fetch trace ids by service and span name. + * Gets "limit" number of entries from before the "end_ts". + * + * Span name is optional. + * Timestamps are in microseconds. + */ + list getTraceIdsBySpanName(1: string service_name, 2: string span_name, + 4: i64 end_ts, 5: i32 limit, 6: Order order) throws (1: QueryException qe); + + /** + * Fetch trace ids by service name. + * Gets "limit" number of entries from before the "end_ts". + * + * Timestamps are in microseconds. + */ + list getTraceIdsByServiceName(1: string service_name, + 3: i64 end_ts, 4: i32 limit, 5: Order order) throws (1: QueryException qe); + + /** + * Fetch trace ids with a particular annotation. + * Gets "limit" number of entries from before the "end_ts". + * + * When requesting based on time based annotations only pass in the first parameter, "annotation" and leave out + * the second "value". If looking for a key-value binary annotation provide both, "annotation" is then the + * key in the key-value. + * + * Timestamps are in microseconds. + */ + list getTraceIdsByAnnotation(1: string service_name, 2: string annotation, 3: binary value, + 5: i64 end_ts, 6: i32 limit, 7: Order order) throws (1: QueryException qe); + + + #************** Fetch traces from id ************** + + /** + * Get the traces that are in the database from the given list of trace ids. + */ + + set tracesExist(1: list trace_ids) throws (1: QueryException qe); + + /** + * Get the full traces associated with the given trace ids. + * + * Second argument is a list of methods of adjusting the trace + * data before returning it. Can be empty. + */ + list getTracesByIds(1: list trace_ids, 2: list adjust) throws (1: QueryException qe); + + /** + * Get the trace timelines associated with the given trace ids. + * This is a convenience method for users that just want to know + * the annotations and the (assumed) order they happened in. + * + * Second argument is a list of methods of adjusting the trace + * data before returning it. Can be empty. + * + * Note that if one of the trace ids does not have any data associated with it, it will not be + * represented in the output list. + */ + list getTraceTimelinesByIds(1: list trace_ids, 2: list adjust) throws (1: QueryException qe); + + /** + * Fetch trace summaries for the given trace ids. + * + * Second argument is a list of methods of adjusting the trace + * data before returning it. Can be empty. + * + * Note that if one of the trace ids does not have any data associated with it, it will not be + * represented in the output list. + */ + list getTraceSummariesByIds(1: list trace_ids, 2: list adjust) throws (1: QueryException qe); + + /** + * Not content with just one of traces, summaries or timelines? Want it all? This is the method for you. + */ + list getTraceCombosByIds(1: list trace_ids, 2: list adjust) throws (1: QueryException qe); + + #************** Misc metadata ************** + + /** + * Fetch all the service names we have seen from now all the way back to the set ttl. + */ + set getServiceNames() throws (1: QueryException qe); + + /** + * Get all the seen span names for a particular service, from now back until the set ttl. + */ + set getSpanNames(1: string service_name) throws (1: QueryException qe); + + #************** TTL related ************** + + /** + * Change the TTL of a trace. If we find an interesting trace we want to keep around for further + * investigation. + */ + void setTraceTimeToLive(1: i64 trace_id, 2: i32 ttl_seconds) throws (1: QueryException qe); + + /** + * Get the TTL in seconds of a specific trace. + */ + i32 getTraceTimeToLive(1: i64 trace_id) throws (1: QueryException qe); + + /** + * Get the data ttl. This is the number of seconds we keep the data around before deleting it. + */ + i32 getDataTimeToLive() throws (1: QueryException qe); + + /** + * Get an aggregate representation of all services paired with every service they call in to. + * This includes information on call counts and mean/stdDev/etc of call durations. The two arguments + * specify epoch time in microseconds. The end time is optional and defaults to one day after the + * start time. + */ + zipkinDependencies.Dependencies getDependencies(1: optional i64 start_time, 2: optional i64 end_time) throws (1: QueryException qe); + + list getTopAnnotations(1: string service_name) throws (1: QueryException qe); + list getTopKeyValueAnnotations(1: string service_name) throws (1: QueryException qe); + + /** + * Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired + * with the lists of every span duration (list) from the server to client. The lists of span durations + * include information on call counts and mean/stdDev/etc of call durations. + * + * The three arguments specify epoch time in microseconds, server side service name and rpc name. The return maps + * contains the key - client_service_name and value - list. + */ + map> getSpanDurations(1: i64 time_stamp, 2: string service_name, 3: string rpc_name); + + /** + * Given a time stamp, server service name, and rpc name, fetch all of the client services calling in paired + * with the lists of every trace Ids (list) from the server to client. + * + * The three arguments specify epoch time in microseconds, server side service name and rpc name. The return maps + * contains the key - client_service_name and value - list. + */ + map> getServiceNamesToTraceIds(1: i64 time_stamp, 2: string service_name, 3: string rpc_name); +} diff --git a/tracing/zipkin/collector.go b/tracing/zipkin/collector.go new file mode 100644 index 000000000..002c9e49a --- /dev/null +++ b/tracing/zipkin/collector.go @@ -0,0 +1,163 @@ +package zipkin + +import ( + "encoding/base64" + "errors" + "fmt" + "net" + "strings" + "time" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/peterbourgon/gokit/log" + "github.com/peterbourgon/gokit/tracing/zipkin/_thrift/gen-go/scribe" +) + +// Collector represents a Zipkin trace collector, which is probably a set of +// remote endpoints. +type Collector interface { + Collect(*Span) error +} + +// ScribeCollector implements Collector by forwarding spans to a Scribe +// service, in batches. +type ScribeCollector struct { + client scribe.Scribe + factory func() (scribe.Scribe, error) + spanc chan *Span + sendc chan struct{} + quitc chan chan struct{} + batch []*scribe.LogEntry + nextSend time.Time + batchInterval time.Duration + batchSize int +} + +// NewScribeCollector returns a new Scribe-backed Collector, ready for use. +func NewScribeCollector(addr string, timeout time.Duration, batchSize int, batchInterval time.Duration) (Collector, error) { + factory := scribeClientFactory(addr, timeout) + client, err := factory() + if err != nil { + return nil, err + } + c := &ScribeCollector{ + client: client, + factory: factory, + spanc: make(chan *Span), + sendc: make(chan struct{}), + batch: []*scribe.LogEntry{}, + nextSend: time.Now().Add(batchInterval), + batchInterval: batchInterval, + batchSize: batchSize, + } + go c.loop() + return c, nil +} + +// Collect implements Collector. +func (c *ScribeCollector) Collect(s *Span) error { + c.spanc <- s + return nil // accepted +} + +func (c *ScribeCollector) loop() { + tickc := time.Tick(c.batchInterval / 10) + + for { + select { + case span := <-c.spanc: + c.batch = append(c.batch, &scribe.LogEntry{ + Category: "zipkin", // TODO parameterize? + Message: serialize(span), + }) + if len(c.batch) >= c.batchSize { + go c.sendNow() + } + + case <-tickc: + if time.Now().After(c.nextSend) { + go c.sendNow() + } + + case <-c.sendc: + c.nextSend = time.Now().Add(c.batchInterval) + if err := c.send(c.batch); err != nil { + log.DefaultLogger.Log("err", err.Error()) + continue + } + c.batch = c.batch[:0] + } + } +} + +func (c *ScribeCollector) sendNow() { + c.sendc <- struct{}{} +} + +func (c *ScribeCollector) send(batch []*scribe.LogEntry) error { + if c.client == nil { + var err error + if c.client, err = c.factory(); err != nil { + return fmt.Errorf("during reconnect: %v", err) + } + } + if rc, err := c.client.Log(c.batch); err != nil { + c.client = nil + return fmt.Errorf("during Log: %v", err) + } else if rc != scribe.ResultCode_OK { + // probably transient error; don't reset client + return fmt.Errorf("remote returned %s", rc) + } + return nil +} + +func scribeClientFactory(addr string, timeout time.Duration) func() (scribe.Scribe, error) { + return func() (scribe.Scribe, error) { + a, err := net.ResolveTCPAddr("tcp", addr) + if err != nil { + return nil, err + } + socket := thrift.NewTSocketFromAddrTimeout(a, timeout) + transport := thrift.NewTFramedTransport(socket) + if err := transport.Open(); err != nil { + socket.Close() + return nil, err + } + proto := thrift.NewTBinaryProtocolTransport(transport) + client := scribe.NewScribeClientProtocol(transport, proto, proto) + return client, nil + } +} + +func serialize(s *Span) string { + t := thrift.NewTMemoryBuffer() + p := thrift.NewTBinaryProtocolTransport(t) + if err := s.Encode().Write(p); err != nil { + panic(err) + } + return base64.StdEncoding.EncodeToString(t.Buffer.Bytes()) +} + +// NopCollector implements Collector but performs no work. +type NopCollector struct{} + +// Collect implements Collector. +func (NopCollector) Collect(*Span) error { return nil } + +// MultiCollector implements Collector by sending spans to all collectors. +type MultiCollector []Collector + +// Collect implements Collector. +func (c MultiCollector) Collect(s *Span) error { + errs := []string{} + for _, collector := range c { + if err := collector.Collect(s); err != nil { + errs = append(errs, err.Error()) + } + } + if len(errs) > 0 { + return errors.New(strings.Join(errs, "; ")) + } + return nil +} diff --git a/tracing/zipkin/collector_test.go b/tracing/zipkin/collector_test.go new file mode 100644 index 000000000..19c253167 --- /dev/null +++ b/tracing/zipkin/collector_test.go @@ -0,0 +1,200 @@ +package zipkin_test + +import ( + "encoding/base64" + "fmt" + "math/rand" + "net" + "sync" + "testing" + "time" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/peterbourgon/gokit/tracing/zipkin" + "github.com/peterbourgon/gokit/tracing/zipkin/_thrift/gen-go/scribe" + "github.com/peterbourgon/gokit/tracing/zipkin/_thrift/gen-go/zipkincore" +) + +func TestScribeCollector(t *testing.T) { + server := newScribeServer(t) + + timeout := time.Second + batchInterval := time.Millisecond + c, err := zipkin.NewScribeCollector(server.addr(), timeout, 0, batchInterval) + if err != nil { + t.Fatal(err) + } + + var ( + name = "span-name" + traceID = int64(123) + spanID = int64(456) + parentSpanID = int64(0) + value = "foo" + duration = 42 * time.Millisecond + ) + + span := zipkin.NewSpan("some-host", name, traceID, spanID, parentSpanID) + span.AnnotateDuration("foo", 42*time.Millisecond) + if err := c.Collect(span); err != nil { + t.Errorf("error during collection: %v", err) + } + + // Need to yield to the select loop to accept the send request, and then + // yield again to the send operation to write to the socket. I think the + // best way to do that is just give it some time. + + deadline := time.Now().Add(1 * time.Second) + for { + if time.Now().After(deadline) { + t.Fatalf("never received a span") + } + if want, have := 1, len(server.spans()); want != have { + time.Sleep(time.Millisecond) + continue + } + break + } + + gotSpan := server.spans()[0] + if want, have := name, gotSpan.GetName(); want != have { + t.Errorf("want %q, have %q", want, have) + } + if want, have := traceID, gotSpan.GetTraceId(); want != have { + t.Errorf("want %d, have %d", want, have) + } + if want, have := spanID, gotSpan.GetId(); want != have { + t.Errorf("want %d, have %d", want, have) + } + if want, have := parentSpanID, gotSpan.GetParentId(); want != have { + t.Errorf("want %d, have %d", want, have) + } + + if want, have := 1, len(gotSpan.GetAnnotations()); want != have { + t.Fatalf("want %d, have %d", want, have) + } + + gotAnnotation := gotSpan.GetAnnotations()[0] + if want, have := value, gotAnnotation.GetValue(); want != have { + t.Errorf("want %q, have %q", want, have) + } + if want, have := duration, time.Duration(gotAnnotation.GetDuration())*time.Microsecond; want != have { + t.Errorf("want %s, have %s", want, have) + } +} + +type scribeServer struct { + t *testing.T + transport *thrift.TServerSocket + address string + server *thrift.TSimpleServer + handler *scribeHandler +} + +func newScribeServer(t *testing.T) *scribeServer { + protocolFactory := thrift.NewTBinaryProtocolFactoryDefault() + transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory()) + + var port int + var transport *thrift.TServerSocket + var err error + for i := 0; i < 10; i++ { + port = 10000 + rand.Intn(10000) + transport, err = thrift.NewTServerSocket(fmt.Sprintf(":%d", port)) + if err != nil { + t.Logf("port %d: %v", port, err) + continue + } + break + } + if err != nil { + t.Fatal(err) + } + + handler := newScribeHandler(t) + server := thrift.NewTSimpleServer4( + scribe.NewScribeProcessor(handler), + transport, + transportFactory, + protocolFactory, + ) + + go server.Serve() + + deadline := time.Now().Add(time.Second) + for !canConnect(port) { + if time.Now().After(deadline) { + t.Fatal("server never started") + } + time.Sleep(time.Millisecond) + } + + return &scribeServer{ + transport: transport, + address: fmt.Sprintf("127.0.0.1:%d", port), + handler: handler, + } +} + +func (s *scribeServer) addr() string { + return s.address +} + +func (s *scribeServer) spans() []*zipkincore.Span { + return s.handler.spans() +} + +type scribeHandler struct { + t *testing.T + sync.RWMutex + entries []*scribe.LogEntry +} + +func newScribeHandler(t *testing.T) *scribeHandler { + return &scribeHandler{t: t} +} + +func (h *scribeHandler) Log(messages []*scribe.LogEntry) (scribe.ResultCode, error) { + h.Lock() + defer h.Unlock() + for _, m := range messages { + h.entries = append(h.entries, m) + } + return scribe.ResultCode_OK, nil +} + +func (h *scribeHandler) spans() []*zipkincore.Span { + h.RLock() + defer h.RUnlock() + spans := []*zipkincore.Span{} + for _, m := range h.entries { + decoded, err := base64.StdEncoding.DecodeString(m.GetMessage()) + if err != nil { + h.t.Error(err) + continue + } + buffer := thrift.NewTMemoryBuffer() + if _, err := buffer.Write(decoded); err != nil { + h.t.Error(err) + continue + } + transport := thrift.NewTBinaryProtocolTransport(buffer) + zs := &zipkincore.Span{} + if err := zs.Read(transport); err != nil { + h.t.Error(err) + continue + } + spans = append(spans, zs) + } + return spans +} + +func canConnect(port int) bool { + c, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", port)) + if err != nil { + return false + } + c.Close() + return true +} diff --git a/tracing/zipkin/span.go b/tracing/zipkin/span.go new file mode 100644 index 000000000..db5d83cb3 --- /dev/null +++ b/tracing/zipkin/span.go @@ -0,0 +1,112 @@ +package zipkin + +import ( + "errors" + "time" + + "github.com/peterbourgon/gokit/tracing/zipkin/_thrift/gen-go/zipkincore" +) + +var ( + // SpanContextKey represents the Span in the request context. + SpanContextKey = "Zipkin-Span" + + // ErrSpanNotFound is returned when a Span isn't found in a context. + ErrSpanNotFound = errors.New("span not found") +) + +// A Span is a named collection of annotations. It represents meaningful +// information about a single method call, i.e. a single request against a +// service. Clients should annotate the span, and submit it when the request +// that generated it is complete. +type Span struct { + host string + name string + traceID int64 + spanID int64 + parentSpanID int64 + + annotations []annotation + //binaryAnnotations []BinaryAnnotation +} + +// NewSpan returns a new Span object ready for use. +func NewSpan(host string, name string, traceID, spanID, parentSpanID int64) *Span { + return &Span{ + host: host, + name: name, + traceID: traceID, + spanID: spanID, + parentSpanID: parentSpanID, + } +} + +// NewSpanFunc returns a function that generates a new Zipkin span. +func NewSpanFunc(host, name string) func(int64, int64, int64) *Span { + return func(traceID, spanID, parentSpanID int64) *Span { + return NewSpan(host, name, traceID, spanID, parentSpanID) + } +} + +// TraceID returns the ID of the trace that this span is a member of. +func (s *Span) TraceID() int64 { return s.traceID } + +// SpanID returns the ID of this span. +func (s *Span) SpanID() int64 { return s.spanID } + +// ParentSpanID returns the ID of the span which invoked this span. +// It may be zero. +func (s *Span) ParentSpanID() int64 { return s.parentSpanID } + +// Annotate annotates the span with the given value. +func (s *Span) Annotate(value string) { + s.AnnotateDuration(value, 0) +} + +// AnnotateDuration annotates the span with the given value and duration. +func (s *Span) AnnotateDuration(value string, duration time.Duration) { + s.annotations = append(s.annotations, annotation{ + timestamp: time.Now(), + value: value, + duration: duration, + host: s.host, + }) +} + +// Encode creates a Thrift Span from the gokit Span. +func (s *Span) Encode() *zipkincore.Span { + // TODO lots of garbage here. We can improve by preallocating e.g. the + // Thrift stuff into an encoder struct, owned by the ScribeCollector. + zs := zipkincore.Span{ + TraceId: s.traceID, + Name: s.name, + Id: s.spanID, + BinaryAnnotations: []*zipkincore.BinaryAnnotation{}, // TODO + Debug: false, // TODO + } + if s.parentSpanID != 0 { + (*zs.ParentId) = s.parentSpanID + } + zs.Annotations = make([]*zipkincore.Annotation, len(s.annotations)) + for i, a := range s.annotations { + zs.Annotations[i] = &zipkincore.Annotation{ + Timestamp: a.timestamp.UnixNano() / 1e3, + Value: a.value, + } + if a.host != "" { + // zs.Annotations[i].Host = TODO + } + if a.duration > 0 { + zs.Annotations[i].Duration = new(int32) + (*zs.Annotations[i].Duration) = int32(a.duration / time.Microsecond) + } + } + return &zs +} + +type annotation struct { + timestamp time.Time + value string + duration time.Duration // optional + host string +} diff --git a/tracing/zipkin/zipkin.go b/tracing/zipkin/zipkin.go new file mode 100644 index 000000000..296b7b513 --- /dev/null +++ b/tracing/zipkin/zipkin.go @@ -0,0 +1,130 @@ +package zipkin + +import ( + "math/rand" + "net/http" + "strconv" + + "golang.org/x/net/context" + + "github.com/peterbourgon/gokit/server" +) + +// http://www.slideshare.net/johanoskarsson/zipkin-runtime-open-house +// https://groups.google.com/forum/#!topic/zipkin-user/KilwtSA0g1k +// https://gist.github.com/yoavaa/3478d3a0df666f21a98c + +const ( + // https://github.com/racker/tryfer#headers + traceIDHTTPHeader = "X-B3-TraceId" + spanIDHTTPHeader = "X-B3-SpanId" + parentSpanIDHTTPHeader = "X-B3-ParentSpanId" + + clientSend = "cs" + serverReceive = "sr" + serverSend = "ss" + clientReceive = "cr" +) + +// AnnotateEndpoint extracts a span from the context, adds server-receive and +// server-send annotations at the boundaries, and submits the span to the +// collector. If no span is present, a new span is generated and put in the +// context. +func AnnotateEndpoint(f func(int64, int64, int64) *Span, c Collector) func(server.Endpoint) server.Endpoint { + return func(e server.Endpoint) server.Endpoint { + return func(ctx context.Context, req server.Request) (server.Response, error) { + span, ctx := mustGetServerSpan(ctx, f) + span.Annotate(serverReceive) + defer func() { span.Annotate(serverSend); c.Collect(span) }() + return e(ctx, req) + } + } +} + +// FromHTTP is a helper method that allows NewSpanFunc's factory function to +// be easily invoked by passing an HTTP request. The span name is the HTTP +// method. The trace, span, and parent span IDs are taken from the request +// headers. +func FromHTTP(f func(int64, int64, int64) *Span) func(*http.Request) *Span { + return func(r *http.Request) *Span { + return f( + getID(r.Header, traceIDHTTPHeader), + getID(r.Header, spanIDHTTPHeader), + getID(r.Header, parentSpanIDHTTPHeader), + ) + } +} + +// ToContext returns a function that satisfies transport/http.BeforeFunc. When +// invoked, it generates a Zipkin span from the incoming HTTP request, and +// saves it in the request context under the SpanContextKey. +func ToContext(f func(*http.Request) *Span) func(context.Context, *http.Request) context.Context { + return func(ctx context.Context, r *http.Request) context.Context { + return context.WithValue(ctx, SpanContextKey, f(r)) + } +} + +// NewChildSpan creates a new child (client) span. If a span is present in the +// context, it will be interpreted as the parent. +func NewChildSpan(ctx context.Context, f func(int64, int64, int64) *Span) *Span { + val := ctx.Value(SpanContextKey) + if val == nil { + return f(newID(), newID(), 0) + } + parentSpan, ok := val.(*Span) + if !ok { + panic(SpanContextKey + " value isn't a span object") + } + var ( + traceID = parentSpan.TraceID() + spanID = newID() + parentSpanID = parentSpan.SpanID() + ) + return f(traceID, spanID, parentSpanID) +} + +// SetRequestHeaders sets up HTTP headers for a new outbound request based on +// the (client) span. All IDs are encoded as hex strings. +func SetRequestHeaders(h http.Header, s *Span) { + if id := s.TraceID(); id > 0 { + h.Set(traceIDHTTPHeader, strconv.FormatInt(id, 16)) + } + if id := s.SpanID(); id > 0 { + h.Set(spanIDHTTPHeader, strconv.FormatInt(id, 16)) + } + if id := s.ParentSpanID(); id > 0 { + h.Set(parentSpanIDHTTPHeader, strconv.FormatInt(id, 16)) + } +} + +func mustGetServerSpan(ctx context.Context, f func(int64, int64, int64) *Span) (*Span, context.Context) { + val := ctx.Value(SpanContextKey) + if val == nil { + span := f(newID(), newID(), 0) + return span, context.WithValue(ctx, SpanContextKey, span) + } + span, ok := val.(*Span) + if !ok { + panic(SpanContextKey + " value isn't a span object") + } + return span, ctx +} + +func getID(h http.Header, key string) int64 { + val := h.Get(key) + if val == "" { + return 0 + } + i, err := strconv.ParseInt(val, 16, 64) + if err != nil { + panic("invalid Zipkin ID in HTTP header: " + val) + } + return i +} + +func newID() int64 { + // https://github.com/wadey/go-zipkin/blob/46e5f01/trace.go#L183-188 + // https://github.com/twitter/zipkin/issues/199 + // :( + return rand.Int63() & 0x001fffffffffffff +} diff --git a/tracing/zipkin/zipkin_test.go b/tracing/zipkin/zipkin_test.go new file mode 100644 index 000000000..95b640eda --- /dev/null +++ b/tracing/zipkin/zipkin_test.go @@ -0,0 +1,133 @@ +package zipkin_test + +import ( + "math/rand" + "net/http" + "strconv" + "sync/atomic" + "testing" + + "github.com/peterbourgon/gokit/server" + + "golang.org/x/net/context" + + "github.com/peterbourgon/gokit/tracing/zipkin" +) + +func TestAnnotateEndpoint(t *testing.T) { + const ( + host = "some-host" + name = "some-name" + ) + + f := zipkin.NewSpanFunc(host, name) + c := &countingCollector{} + + var e server.Endpoint + e = func(context.Context, server.Request) (server.Response, error) { return struct{}{}, nil } + e = zipkin.AnnotateEndpoint(f, c)(e) + + if want, have := int32(0), int32(c.int32); want != have { + t.Errorf("want %d, have %d", want, have) + } + if _, err := e(context.Background(), struct{}{}); err != nil { + t.Fatal(err) + } + if want, have := int32(1), int32(c.int32); want != have { + t.Errorf("want %d, have %d", want, have) + } +} + +func TestFromHTTPToContext(t *testing.T) { + const ( + host = "foo-host" + name = "foo-name" + traceID int64 = 12 + spanID int64 = 34 + parentSpanID int64 = 56 + ) + + r, _ := http.NewRequest("GET", "https://best.horse", nil) + r.Header.Set("X-B3-TraceId", strconv.FormatInt(traceID, 16)) + r.Header.Set("X-B3-SpanId", strconv.FormatInt(spanID, 16)) + r.Header.Set("X-B3-ParentSpanId", strconv.FormatInt(parentSpanID, 16)) + + sf := zipkin.NewSpanFunc(host, name) + hf := zipkin.FromHTTP(sf) + cf := zipkin.ToContext(hf) + + ctx := cf(context.Background(), r) + val := ctx.Value(zipkin.SpanContextKey) + if val == nil { + t.Fatalf("%s returned no value", zipkin.SpanContextKey) + } + span, ok := val.(*zipkin.Span) + if !ok { + t.Fatalf("%s was not a Span object", zipkin.SpanContextKey) + } + + if want, have := traceID, span.TraceID(); want != have { + t.Errorf("want %d, have %d", want, have) + } + + if want, have := spanID, span.SpanID(); want != have { + t.Errorf("want %d, have %d", want, have) + } + + if want, have := parentSpanID, span.ParentSpanID(); want != have { + t.Errorf("want %d, have %d", want, have) + } +} + +func TestNewChildSpan(t *testing.T) { + rand.Seed(123) + + const ( + host = "my-host" + name = "my-name" + traceID int64 = 123 + spanID int64 = 456 + parentSpanID int64 = 789 + ) + + f := zipkin.NewSpanFunc(host, name) + ctx := context.WithValue(context.Background(), zipkin.SpanContextKey, f(traceID, spanID, parentSpanID)) + childSpan := zipkin.NewChildSpan(ctx, f) + + if want, have := traceID, childSpan.TraceID(); want != have { + t.Errorf("want %d, have %d", want, have) + } + if have := childSpan.SpanID(); have == spanID { + t.Errorf("span ID should be random, but we have %d", have) + } + if want, have := spanID, childSpan.ParentSpanID(); want != have { + t.Errorf("want %d, have %d", want, have) + } +} + +func TestSetRequestHeaders(t *testing.T) { + const ( + host = "bar-host" + name = "bar-name" + traceID int64 = 123 + spanID int64 = 456 + parentSpanID int64 = 789 + ) + + r, _ := http.NewRequest("POST", "http://destroy.horse", nil) + zipkin.SetRequestHeaders(r.Header, zipkin.NewSpan(host, name, traceID, spanID, parentSpanID)) + + for h, want := range map[string]string{ + "X-B3-TraceId": strconv.FormatInt(traceID, 16), + "X-B3-SpanId": strconv.FormatInt(spanID, 16), + "X-B3-ParentSpanId": strconv.FormatInt(parentSpanID, 16), + } { + if have := r.Header.Get(h); want != have { + t.Errorf("%s: want %s, have %s", h, want, have) + } + } +} + +type countingCollector struct{ int32 } + +func (c *countingCollector) Collect(*zipkin.Span) error { atomic.AddInt32(&(c.int32), 1); return nil } diff --git a/transport/codec/codec.go b/transport/codec/codec.go new file mode 100644 index 000000000..6df01752f --- /dev/null +++ b/transport/codec/codec.go @@ -0,0 +1,17 @@ +package codec + +import ( + "io" + + "golang.org/x/net/context" + + "github.com/peterbourgon/gokit/server" +) + +// Codec defines how to decode and encode requests and responses. Decode takes +// and returns a context because the request may be accompanied by information +// that needs to be applied there. +type Codec interface { + Decode(context.Context, io.Reader) (server.Request, context.Context, error) + Encode(io.Writer, server.Response) error +} diff --git a/transport/http/before_after.go b/transport/http/before_after.go new file mode 100644 index 000000000..bff51c6d3 --- /dev/null +++ b/transport/http/before_after.go @@ -0,0 +1,25 @@ +package http + +import ( + "net/http" + + "golang.org/x/net/context" +) + +// BeforeFunc may take information from a HTTP request and put it into a +// request context. BeforeFuncs are executed in HTTP bindings, prior to +// invoking the endpoint. +type BeforeFunc func(context.Context, *http.Request) context.Context + +// AfterFunc may take information from a request context and use it to +// manipulate a ResponseWriter. AfterFuncs are executed in HTTP bindings, +// after invoking the endpoint but prior to writing a response. +type AfterFunc func(context.Context, http.ResponseWriter) + +// SetContentType returns an AfterFunc that sets the HTTP Content-Type header +// to the provided value. +func SetContentType(value string) AfterFunc { + return func(_ context.Context, w http.ResponseWriter) { + w.Header().Set("Content-Type", value) + } +} diff --git a/transport/http/binding.go b/transport/http/binding.go new file mode 100644 index 000000000..c5c9991aa --- /dev/null +++ b/transport/http/binding.go @@ -0,0 +1,80 @@ +package http + +import ( + "net/http" + + "golang.org/x/net/context" + + "github.com/peterbourgon/gokit/server" + "github.com/peterbourgon/gokit/transport/codec" +) + +// BindingOption sets a parameter for the binding. +type BindingOption func(*binding) + +// Before adds pre-RPC BeforeFuncs to the binding. +func Before(funcs ...BeforeFunc) BindingOption { + return func(b *binding) { b.before = append(b.before, funcs...) } +} + +// After adds post-RPC AfterFuncs to the binding. +func After(funcs ...AfterFunc) BindingOption { + return func(b *binding) { b.after = append(b.after, funcs...) } +} + +type binding struct { + context.Context + codec.Codec + server.Endpoint + before []BeforeFunc + after []AfterFunc +} + +// NewBinding returns an HTTP handler that wraps the given endpoint. +func NewBinding(ctx context.Context, cdc codec.Codec, endpoint server.Endpoint, options ...BindingOption) http.Handler { + b := &binding{ + Context: ctx, + Codec: cdc, + Endpoint: endpoint, + } + for _, option := range options { + option(b) + } + return b +} + +func (b *binding) ServeHTTP(w http.ResponseWriter, r *http.Request) { + // Per-request context. + ctx, cancel := context.WithCancel(b.Context) + defer cancel() + + // Prepare the RPC's context with details from the request. + for _, f := range b.before { + ctx = f(ctx, r) + } + + // Decode request. + req, ctx, err := b.Codec.Decode(ctx, r.Body) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + // Execute RPC. + resp, err := b.Endpoint(ctx, req) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + // Prepare the ResponseWriter. + for _, f := range b.after { + f(ctx, w) + } + + // Encode response. + if err := b.Codec.Encode(w, resp); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } +} diff --git a/update_deps.bash b/update_deps.bash new file mode 100755 index 000000000..5af470f69 --- /dev/null +++ b/update_deps.bash @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# This script updates each non-stdlib, non-gokit dependency to its most recent +# commit. It can be invoked to aid in debugging after a dependency-related +# failure on continuous integration. + +function deps { + go list -f '{{join .Deps "\n"}}' ./... +} + +function not_stdlib { + xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' +} + +function not_gokit { + grep -v 'peterbourgon/gokit' +} + +function go_get_update { + while read d ; do + echo $d + go get -u $d + done +} + +deps | not_stdlib | not_gokit | go_get_update +