diff --git a/Makefile b/Makefile index 07c135028d2..e7687b74cb2 100644 --- a/Makefile +++ b/Makefile @@ -506,3 +506,10 @@ proto: -Iidl/proto \ --gogo_out=plugins=grpc,$(PROTO_GOGO_MAPPINGS):$(PWD)/proto-gen/zipkin \ idl/proto/zipkin.proto + +.PHONY: proto-hotrod +proto-hotrod: + $(PROTOC) \ + $(PROTO_INCLUDES) \ + --gogo_out=plugins=grpc,$(PROTO_GOGO_MAPPINGS):$(PWD)/ \ + examples/hotrod/services/driver/driver.proto diff --git a/cmd/opentelemetry/go.sum b/cmd/opentelemetry/go.sum index a6c0795ae35..315c6d595ff 100644 --- a/cmd/opentelemetry/go.sum +++ b/cmd/opentelemetry/go.sum @@ -663,6 +663,7 @@ github.com/grpc-ecosystem/grpc-gateway v1.13.0 h1:sBDQoHXrOlfPobnKw69FIKa1wg9qsL github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.14.5 h1:aiLxiiVzAXb7wb3lAmubA69IokWOoUNe+E7TdGKh8yw= github.com/grpc-ecosystem/grpc-gateway v1.14.5/go.mod h1:UJ0EZAp832vCd54Wev9N1BMKEyvcZ5+IM0AwDrnlkEc= +github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= @@ -965,6 +966,7 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +github.com/opentracing-contrib/go-grpc v0.0.0-20191001143057-db30781987df/go.mod h1:DYR5Eij8rJl8h7gblRrOZ8g0kW1umSpKqYIBTgeDtLo= github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9 h1:QsgXACQhd9QJhEmRumbsMQQvBtmdS0mafoVEBplWXEg= github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9/go.mod h1:PLldrQSroqzH70Xl+1DQcGnefIbqsKR7UDaiux3zV+w= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1392,6 +1394,7 @@ golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190921015927-1a5e07d1ff72/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1615,6 +1618,7 @@ google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0 h1:AzbTB6ux+okLTzP8Ru1Xs41C303zdcfEht7MQnYJt5A= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= diff --git a/examples/hotrod/services/driver/client.go b/examples/hotrod/services/driver/client.go index 09658b9bc03..19b894aba4e 100644 --- a/examples/hotrod/services/driver/client.go +++ b/examples/hotrod/services/driver/client.go @@ -19,44 +19,36 @@ import ( "context" "time" + otgrpc "github.com/opentracing-contrib/go-grpc" + "google.golang.org/grpc" "github.com/opentracing/opentracing-go" - "github.com/uber/tchannel-go" - "github.com/uber/tchannel-go/thrift" "go.uber.org/zap" "github.com/jaegertracing/jaeger/examples/hotrod/pkg/log" - "github.com/jaegertracing/jaeger/examples/hotrod/services/driver/thrift-gen/driver" ) // Client is a remote client that implements driver.Interface type Client struct { tracer opentracing.Tracer logger log.Factory - ch *tchannel.Channel - client driver.TChanDriver + client DriverServiceClient } // NewClient creates a new driver.Client func NewClient(tracer opentracing.Tracer, logger log.Factory, hostPort string) *Client { - channelOpts := &tchannel.ChannelOptions{ - //Logger: logger, - //StatsReporter: statsReporter, - Tracer: tracer, - } - ch, err := tchannel.NewChannel("driver-client", channelOpts) + conn, err := grpc.Dial(hostPort, grpc.WithInsecure(), + grpc.WithUnaryInterceptor( + otgrpc.OpenTracingClientInterceptor(tracer)), + grpc.WithStreamInterceptor( + otgrpc.OpenTracingStreamClientInterceptor(tracer))) if err != nil { - logger.Bg().Fatal("Cannot create TChannel", zap.Error(err)) - } - clientOpts := &thrift.ClientOptions{ - HostPort: hostPort, + logger.Bg().Fatal("Cannot create gRPC connection", zap.Error(err)) } - thriftClient := thrift.NewClient(ch, "driver", clientOpts) - client := driver.NewTChanDriverClient(thriftClient) + client := NewDriverServiceClient(conn) return &Client{ tracer: tracer, logger: logger, - ch: ch, client: client, } } @@ -66,16 +58,16 @@ func (c *Client) FindNearest(ctx context.Context, location string) ([]Driver, er c.logger.For(ctx).Info("Finding nearest drivers", zap.String("location", location)) ctx, cancel := context.WithTimeout(ctx, 1*time.Second) defer cancel() - results, err := c.client.FindNearest(thrift.Wrap(ctx), location) + response, err := c.client.FindNearest(ctx, &DriverLocationRequest{Location: location}) if err != nil { return nil, err } - return fromThrift(results), nil + return fromProto(response), nil } -func fromThrift(results []*driver.DriverLocation) []Driver { - retMe := make([]Driver, len(results)) - for i, result := range results { +func fromProto(response *DriverLocationResponse) []Driver { + retMe := make([]Driver, len(response.Locations)) + for i, result := range response.Locations { retMe[i] = Driver{ DriverID: result.DriverID, Location: result.Location, diff --git a/examples/hotrod/services/driver/driver.pb.go b/examples/hotrod/services/driver/driver.pb.go new file mode 100644 index 00000000000..9f0d0db9944 --- /dev/null +++ b/examples/hotrod/services/driver/driver.pb.go @@ -0,0 +1,260 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. + +// Copyright (c) 2020 The Jaeger Authors. +// +// 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. + +// source: examples/hotrod/services/driver/driver.proto + +package driver + +import ( + context "context" + fmt "fmt" + math "math" + + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +type DriverLocationRequest struct { + Location string `protobuf:"bytes,1,opt,name=location,proto3" json:"location,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DriverLocationRequest) Reset() { *m = DriverLocationRequest{} } +func (m *DriverLocationRequest) String() string { return proto.CompactTextString(m) } +func (*DriverLocationRequest) ProtoMessage() {} +func (*DriverLocationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_cdcd28b7ebdcd54f, []int{0} +} +func (m *DriverLocationRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DriverLocationRequest.Unmarshal(m, b) +} +func (m *DriverLocationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DriverLocationRequest.Marshal(b, m, deterministic) +} +func (m *DriverLocationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DriverLocationRequest.Merge(m, src) +} +func (m *DriverLocationRequest) XXX_Size() int { + return xxx_messageInfo_DriverLocationRequest.Size(m) +} +func (m *DriverLocationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DriverLocationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DriverLocationRequest proto.InternalMessageInfo + +func (m *DriverLocationRequest) GetLocation() string { + if m != nil { + return m.Location + } + return "" +} + +type DriverLocation struct { + DriverID string `protobuf:"bytes,1,opt,name=driverID,proto3" json:"driverID,omitempty"` + Location string `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DriverLocation) Reset() { *m = DriverLocation{} } +func (m *DriverLocation) String() string { return proto.CompactTextString(m) } +func (*DriverLocation) ProtoMessage() {} +func (*DriverLocation) Descriptor() ([]byte, []int) { + return fileDescriptor_cdcd28b7ebdcd54f, []int{1} +} +func (m *DriverLocation) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DriverLocation.Unmarshal(m, b) +} +func (m *DriverLocation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DriverLocation.Marshal(b, m, deterministic) +} +func (m *DriverLocation) XXX_Merge(src proto.Message) { + xxx_messageInfo_DriverLocation.Merge(m, src) +} +func (m *DriverLocation) XXX_Size() int { + return xxx_messageInfo_DriverLocation.Size(m) +} +func (m *DriverLocation) XXX_DiscardUnknown() { + xxx_messageInfo_DriverLocation.DiscardUnknown(m) +} + +var xxx_messageInfo_DriverLocation proto.InternalMessageInfo + +func (m *DriverLocation) GetDriverID() string { + if m != nil { + return m.DriverID + } + return "" +} + +func (m *DriverLocation) GetLocation() string { + if m != nil { + return m.Location + } + return "" +} + +type DriverLocationResponse struct { + Locations []*DriverLocation `protobuf:"bytes,1,rep,name=locations,proto3" json:"locations,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DriverLocationResponse) Reset() { *m = DriverLocationResponse{} } +func (m *DriverLocationResponse) String() string { return proto.CompactTextString(m) } +func (*DriverLocationResponse) ProtoMessage() {} +func (*DriverLocationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cdcd28b7ebdcd54f, []int{2} +} +func (m *DriverLocationResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DriverLocationResponse.Unmarshal(m, b) +} +func (m *DriverLocationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DriverLocationResponse.Marshal(b, m, deterministic) +} +func (m *DriverLocationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DriverLocationResponse.Merge(m, src) +} +func (m *DriverLocationResponse) XXX_Size() int { + return xxx_messageInfo_DriverLocationResponse.Size(m) +} +func (m *DriverLocationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DriverLocationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DriverLocationResponse proto.InternalMessageInfo + +func (m *DriverLocationResponse) GetLocations() []*DriverLocation { + if m != nil { + return m.Locations + } + return nil +} + +func init() { + proto.RegisterType((*DriverLocationRequest)(nil), "driver.DriverLocationRequest") + proto.RegisterType((*DriverLocation)(nil), "driver.DriverLocation") + proto.RegisterType((*DriverLocationResponse)(nil), "driver.DriverLocationResponse") +} + +func init() { + proto.RegisterFile("examples/hotrod/services/driver/driver.proto", fileDescriptor_cdcd28b7ebdcd54f) +} + +var fileDescriptor_cdcd28b7ebdcd54f = []byte{ + // 207 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x49, 0xad, 0x48, 0xcc, + 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0xcf, 0xc8, 0x2f, 0x29, 0xca, 0x4f, 0xd1, 0x2f, 0x4e, 0x2d, 0x2a, + 0xcb, 0x4c, 0x4e, 0x2d, 0xd6, 0x4f, 0x29, 0xca, 0x2c, 0x4b, 0x2d, 0x82, 0x52, 0x7a, 0x05, 0x45, + 0xf9, 0x25, 0xf9, 0x42, 0x6c, 0x10, 0x9e, 0x92, 0x31, 0x97, 0xa8, 0x0b, 0x98, 0xe5, 0x93, 0x9f, + 0x9c, 0x58, 0x92, 0x99, 0x9f, 0x17, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x22, 0x24, 0xc5, 0xc5, + 0x91, 0x03, 0x15, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x82, 0xf3, 0x95, 0x3c, 0xb8, 0xf8, + 0x50, 0x35, 0x81, 0x54, 0x43, 0x0c, 0xf4, 0x74, 0x81, 0xa9, 0x86, 0xf1, 0x51, 0x4c, 0x62, 0x42, + 0x33, 0xc9, 0x8f, 0x4b, 0x0c, 0xdd, 0xfa, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x21, 0x13, 0x2e, + 0x4e, 0x98, 0xaa, 0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0xa8, 0x17, 0xd0, + 0xb4, 0x20, 0x14, 0x1a, 0xc5, 0x72, 0xf1, 0x42, 0x24, 0x83, 0x21, 0x9e, 0x17, 0xf2, 0xe1, 0xe2, + 0x76, 0xcb, 0xcc, 0x4b, 0xf1, 0x4b, 0x4d, 0x2c, 0x02, 0xf9, 0x4a, 0x16, 0x87, 0x11, 0x10, 0x4f, + 0x4b, 0xc9, 0xe1, 0x92, 0x86, 0x38, 0xca, 0x89, 0x23, 0x0a, 0x1a, 0x6e, 0x49, 0x6c, 0xe0, 0x60, + 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x90, 0x0b, 0x66, 0x76, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// DriverServiceClient is the client API for DriverService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type DriverServiceClient interface { + FindNearest(ctx context.Context, in *DriverLocationRequest, opts ...grpc.CallOption) (*DriverLocationResponse, error) +} + +type driverServiceClient struct { + cc *grpc.ClientConn +} + +func NewDriverServiceClient(cc *grpc.ClientConn) DriverServiceClient { + return &driverServiceClient{cc} +} + +func (c *driverServiceClient) FindNearest(ctx context.Context, in *DriverLocationRequest, opts ...grpc.CallOption) (*DriverLocationResponse, error) { + out := new(DriverLocationResponse) + err := c.cc.Invoke(ctx, "/driver.DriverService/FindNearest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DriverServiceServer is the server API for DriverService service. +type DriverServiceServer interface { + FindNearest(context.Context, *DriverLocationRequest) (*DriverLocationResponse, error) +} + +func RegisterDriverServiceServer(s *grpc.Server, srv DriverServiceServer) { + s.RegisterService(&_DriverService_serviceDesc, srv) +} + +func _DriverService_FindNearest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DriverLocationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DriverServiceServer).FindNearest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/driver.DriverService/FindNearest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DriverServiceServer).FindNearest(ctx, req.(*DriverLocationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _DriverService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "driver.DriverService", + HandlerType: (*DriverServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "FindNearest", + Handler: _DriverService_FindNearest_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "examples/hotrod/services/driver/driver.proto", +} diff --git a/examples/hotrod/services/driver/driver.proto b/examples/hotrod/services/driver/driver.proto new file mode 100644 index 00000000000..0d9d98db7bd --- /dev/null +++ b/examples/hotrod/services/driver/driver.proto @@ -0,0 +1,35 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// 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. + +syntax="proto3"; +package driver; + +option go_package = "driver"; + +message DriverLocationRequest { + string location = 1; +} + +message DriverLocation { + string driverID = 1; + string location = 2; +} + +message DriverLocationResponse { + repeated DriverLocation locations = 1; +} + +service DriverService { + rpc FindNearest(DriverLocationRequest) returns (DriverLocationResponse); +} diff --git a/examples/hotrod/services/driver/driver.thrift b/examples/hotrod/services/driver/driver.thrift deleted file mode 100644 index 0b6778f3b51..00000000000 --- a/examples/hotrod/services/driver/driver.thrift +++ /dev/null @@ -1,9 +0,0 @@ - -struct DriverLocation { - 1: required string driver_id - 2: required string location -} - -service Driver { - list findNearest(1: string location) -} \ No newline at end of file diff --git a/examples/hotrod/services/driver/server.go b/examples/hotrod/services/driver/server.go index 15c8c215e1c..6089e2141ad 100644 --- a/examples/hotrod/services/driver/server.go +++ b/examples/hotrod/services/driver/server.go @@ -16,14 +16,16 @@ package driver import ( + "context" + "net" + + otgrpc "github.com/opentracing-contrib/go-grpc" "github.com/opentracing/opentracing-go" "github.com/uber/jaeger-lib/metrics" - "github.com/uber/tchannel-go" - "github.com/uber/tchannel-go/thrift" "go.uber.org/zap" + "google.golang.org/grpc" "github.com/jaegertracing/jaeger/examples/hotrod/pkg/log" - "github.com/jaegertracing/jaeger/examples/hotrod/services/driver/thrift-gen/driver" ) // Server implements jaeger-demo-frontend service @@ -31,54 +33,47 @@ type Server struct { hostPort string tracer opentracing.Tracer logger log.Factory - ch *tchannel.Channel - server *thrift.Server redis *Redis + server *grpc.Server } +var _ DriverServiceServer = (*Server)(nil) + // NewServer creates a new driver.Server func NewServer(hostPort string, tracer opentracing.Tracer, metricsFactory metrics.Factory, logger log.Factory) *Server { - channelOpts := &tchannel.ChannelOptions{ - Tracer: tracer, - } - ch, err := tchannel.NewChannel("driver", channelOpts) - if err != nil { - logger.Bg().Fatal("Cannot create TChannel", zap.Error(err)) - } - server := thrift.NewServer(ch) - + server := grpc.NewServer(grpc.UnaryInterceptor( + otgrpc.OpenTracingServerInterceptor(tracer)), + grpc.StreamInterceptor( + otgrpc.OpenTracingStreamServerInterceptor(tracer))) return &Server{ hostPort: hostPort, tracer: tracer, logger: logger, - ch: ch, - server: server, + server: server, redis: newRedis(metricsFactory, logger), } } // Run starts the Driver server func (s *Server) Run() error { - - s.server.Register(driver.NewTChanDriverServer(s)) - - if err := s.ch.ListenAndServe(s.hostPort); err != nil { - s.logger.Bg().Fatal("Unable to start tchannel server", zap.Error(err)) + lis, err := net.Listen("tcp", s.hostPort) + if err != nil { + s.logger.Bg().Fatal("Unable to create http listener", zap.Error(err)) } - - peerInfo := s.ch.PeerInfo() - s.logger.Bg().Info("TChannel listening", zap.String("hostPort", peerInfo.HostPort)) - - // Run must block, but TChannel's ListenAndServe runs in the background, so block indefinitely - select {} + RegisterDriverServiceServer(s.server, s) + err = s.server.Serve(lis) + if err != nil { + s.logger.Bg().Fatal("Unable to start gRPC server", zap.Error(err)) + } + return err } -// FindNearest implements Thrift interface TChanDriver -func (s *Server) FindNearest(ctx thrift.Context, location string) ([]*driver.DriverLocation, error) { - s.logger.For(ctx).Info("Searching for nearby drivers", zap.String("location", location)) - driverIDs := s.redis.FindDriverIDs(ctx, location) +// FindNearest implements gRPC driver interface +func (s *Server) FindNearest(ctx context.Context, location *DriverLocationRequest) (*DriverLocationResponse, error) { + s.logger.For(ctx).Info("Searching for nearby drivers", zap.String("location", location.Location)) + driverIDs := s.redis.FindDriverIDs(ctx, location.Location) - retMe := make([]*driver.DriverLocation, len(driverIDs)) + retMe := make([]*DriverLocation, len(driverIDs)) for i, driverID := range driverIDs { var drv Driver var err error @@ -93,11 +88,11 @@ func (s *Server) FindNearest(ctx thrift.Context, location string) ([]*driver.Dri s.logger.For(ctx).Error("Failed to get driver after 3 attempts", zap.Error(err)) return nil, err } - retMe[i] = &driver.DriverLocation{ + retMe[i] = &DriverLocation{ DriverID: drv.DriverID, Location: drv.Location, } } s.logger.For(ctx).Info("Search successful", zap.Int("num_drivers", len(retMe))) - return retMe, nil + return &DriverLocationResponse{Locations: retMe}, nil } diff --git a/examples/hotrod/services/driver/thrift-gen/driver/constants.go b/examples/hotrod/services/driver/thrift-gen/driver/constants.go deleted file mode 100644 index 09d65670e77..00000000000 --- a/examples/hotrod/services/driver/thrift-gen/driver/constants.go +++ /dev/null @@ -1,18 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package driver - -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/examples/hotrod/services/driver/thrift-gen/driver/driver.go b/examples/hotrod/services/driver/thrift-gen/driver/driver.go deleted file mode 100644 index c8b202751fc..00000000000 --- a/examples/hotrod/services/driver/thrift-gen/driver/driver.go +++ /dev/null @@ -1,427 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package driver - -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 Driver interface { - // Parameters: - // - Location - FindNearest(location string) (r []*DriverLocation, err error) -} - -type DriverClient struct { - Transport thrift.TTransport - ProtocolFactory thrift.TProtocolFactory - InputProtocol thrift.TProtocol - OutputProtocol thrift.TProtocol - SeqId int32 -} - -func NewDriverClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *DriverClient { - return &DriverClient{Transport: t, - ProtocolFactory: f, - InputProtocol: f.GetProtocol(t), - OutputProtocol: f.GetProtocol(t), - SeqId: 0, - } -} - -func NewDriverClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *DriverClient { - return &DriverClient{Transport: t, - ProtocolFactory: nil, - InputProtocol: iprot, - OutputProtocol: oprot, - SeqId: 0, - } -} - -// Parameters: -// - Location -func (p *DriverClient) FindNearest(location string) (r []*DriverLocation, err error) { - if err = p.sendFindNearest(location); err != nil { - return - } - return p.recvFindNearest() -} - -func (p *DriverClient) sendFindNearest(location string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("findNearest", thrift.CALL, p.SeqId); err != nil { - return - } - args := DriverFindNearestArgs{ - Location: location, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *DriverClient) recvFindNearest() (value []*DriverLocation, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "findNearest" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "findNearest failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "findNearest failed: out of sequence response") - 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 mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "findNearest failed: invalid message type") - return - } - result := DriverFindNearestResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -type DriverProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler Driver -} - -func (p *DriverProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *DriverProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *DriverProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewDriverProcessor(handler Driver) *DriverProcessor { - - self2 := &DriverProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self2.processorMap["findNearest"] = &driverProcessorFindNearest{handler: handler} - return self2 -} - -func (p *DriverProcessor) 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 driverProcessorFindNearest struct { - handler Driver -} - -func (p *driverProcessorFindNearest) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := DriverFindNearestArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("findNearest", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := DriverFindNearestResult{} - var retval []*DriverLocation - var err2 error - if retval, err2 = p.handler.FindNearest(args.Location); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing findNearest: "+err2.Error()) - oprot.WriteMessageBegin("findNearest", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("findNearest", 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 - -// Attributes: -// - Location -type DriverFindNearestArgs struct { - Location string `thrift:"location,1" json:"location"` -} - -func NewDriverFindNearestArgs() *DriverFindNearestArgs { - return &DriverFindNearestArgs{} -} - -func (p *DriverFindNearestArgs) GetLocation() string { - return p.Location -} -func (p *DriverFindNearestArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", 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 thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DriverFindNearestArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Location = v - } - return nil -} - -func (p *DriverFindNearestArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("findNearest_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *DriverFindNearestArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("location", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:location: ", p), err) - } - if err := oprot.WriteString(string(p.Location)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.location (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:location: ", p), err) - } - return err -} - -func (p *DriverFindNearestArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("DriverFindNearestArgs(%+v)", *p) -} - -// Attributes: -// - Success -type DriverFindNearestResult struct { - Success []*DriverLocation `thrift:"success,0" json:"success,omitempty"` -} - -func NewDriverFindNearestResult() *DriverFindNearestResult { - return &DriverFindNearestResult{} -} - -var DriverFindNearestResult_Success_DEFAULT []*DriverLocation - -func (p *DriverFindNearestResult) GetSuccess() []*DriverLocation { - return p.Success -} -func (p *DriverFindNearestResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *DriverFindNearestResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", 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 thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DriverFindNearestResult) readField0(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*DriverLocation, 0, size) - p.Success = tSlice - for i := 0; i < size; i++ { - _elem4 := &DriverLocation{} - if err := _elem4.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem4), err) - } - p.Success = append(p.Success, _elem4) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *DriverFindNearestResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("findNearest_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *DriverFindNearestResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Success { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *DriverFindNearestResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("DriverFindNearestResult(%+v)", *p) -} diff --git a/examples/hotrod/services/driver/thrift-gen/driver/tchan-driver.go b/examples/hotrod/services/driver/thrift-gen/driver/tchan-driver.go deleted file mode 100644 index d69dfd23794..00000000000 --- a/examples/hotrod/services/driver/thrift-gen/driver/tchan-driver.go +++ /dev/null @@ -1,101 +0,0 @@ -// @generated Code generated by thrift-gen. Do not modify. - -// Package driver is generated code used to make or handle TChannel calls using Thrift. -package driver - -import ( - "fmt" - - athrift "github.com/apache/thrift/lib/go/thrift" - "github.com/uber/tchannel-go/thrift" -) - -// Interfaces for the service and client for the services defined in the IDL. - -// TChanDriver is the interface that defines the server handler and client interface. -type TChanDriver interface { - FindNearest(ctx thrift.Context, location string) ([]*DriverLocation, error) -} - -// Implementation of a client and service handler. - -type tchanDriverClient struct { - thriftService string - client thrift.TChanClient -} - -func NewTChanDriverInheritedClient(thriftService string, client thrift.TChanClient) *tchanDriverClient { - return &tchanDriverClient{ - thriftService, - client, - } -} - -// NewTChanDriverClient creates a client that can be used to make remote calls. -func NewTChanDriverClient(client thrift.TChanClient) TChanDriver { - return NewTChanDriverInheritedClient("Driver", client) -} - -func (c *tchanDriverClient) FindNearest(ctx thrift.Context, location string) ([]*DriverLocation, error) { - var resp DriverFindNearestResult - args := DriverFindNearestArgs{ - Location: location, - } - success, err := c.client.Call(ctx, c.thriftService, "findNearest", &args, &resp) - if err == nil && !success { - } - - return resp.GetSuccess(), err -} - -type tchanDriverServer struct { - handler TChanDriver -} - -// NewTChanDriverServer wraps a handler for TChanDriver so it can be -// registered with a thrift.Server. -func NewTChanDriverServer(handler TChanDriver) thrift.TChanServer { - return &tchanDriverServer{ - handler, - } -} - -func (s *tchanDriverServer) Service() string { - return "Driver" -} - -func (s *tchanDriverServer) Methods() []string { - return []string{ - "findNearest", - } -} - -func (s *tchanDriverServer) Handle(ctx thrift.Context, methodName string, protocol athrift.TProtocol) (bool, athrift.TStruct, error) { - switch methodName { - case "findNearest": - return s.handleFindNearest(ctx, protocol) - - default: - return false, nil, fmt.Errorf("method %v not found in service %v", methodName, s.Service()) - } -} - -func (s *tchanDriverServer) handleFindNearest(ctx thrift.Context, protocol athrift.TProtocol) (bool, athrift.TStruct, error) { - var req DriverFindNearestArgs - var res DriverFindNearestResult - - if err := req.Read(protocol); err != nil { - return false, nil, err - } - - r, err := - s.handler.FindNearest(ctx, req.Location) - - if err != nil { - return false, nil, err - } else { - res.Success = r - } - - return err == nil, &res, nil -} diff --git a/examples/hotrod/services/driver/thrift-gen/driver/ttypes.go b/examples/hotrod/services/driver/thrift-gen/driver/ttypes.go deleted file mode 100644 index 2f5093b1424..00000000000 --- a/examples/hotrod/services/driver/thrift-gen/driver/ttypes.go +++ /dev/null @@ -1,154 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package driver - -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 - -// Attributes: -// - DriverID -// - Location -type DriverLocation struct { - DriverID string `thrift:"driver_id,1,required" json:"driver_id"` - Location string `thrift:"location,2,required" json:"location"` -} - -func NewDriverLocation() *DriverLocation { - return &DriverLocation{} -} - -func (p *DriverLocation) GetDriverID() string { - return p.DriverID -} - -func (p *DriverLocation) GetLocation() string { - return p.Location -} -func (p *DriverLocation) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - var issetDriverID bool = false - var issetLocation bool = false - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - issetDriverID = true - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - issetLocation = true - 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 thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - if !issetDriverID { - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field DriverID is not set")) - } - if !issetLocation { - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Location is not set")) - } - return nil -} - -func (p *DriverLocation) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.DriverID = v - } - return nil -} - -func (p *DriverLocation) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Location = v - } - return nil -} - -func (p *DriverLocation) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DriverLocation"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", 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 thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *DriverLocation) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("driver_id", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:driver_id: ", p), err) - } - if err := oprot.WriteString(string(p.DriverID)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.driver_id (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:driver_id: ", p), err) - } - return err -} - -func (p *DriverLocation) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("location", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:location: ", p), err) - } - if err := oprot.WriteString(string(p.Location)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.location (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:location: ", p), err) - } - return err -} - -func (p *DriverLocation) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("DriverLocation(%+v)", *p) -} diff --git a/go.mod b/go.mod index d665e0ead01..37bb5b04961 100644 --- a/go.mod +++ b/go.mod @@ -48,6 +48,7 @@ require ( github.com/mjibson/esc v0.2.0 github.com/oklog/run v1.1.0 // indirect github.com/olivere/elastic v6.2.27+incompatible + github.com/opentracing-contrib/go-grpc v0.0.0-20191001143057-db30781987df github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9 github.com/opentracing/opentracing-go v1.1.0 github.com/pelletier/go-toml v1.6.0 // indirect diff --git a/go.sum b/go.sum index 7f1ed774ea9..822ec940c34 100644 --- a/go.sum +++ b/go.sum @@ -229,6 +229,7 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.13.0 h1:sBDQoHXrOlfPobnKw69FIKa1wg9qsLLvvQ/Y19WtFgI= github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= +github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= @@ -325,6 +326,8 @@ github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0 github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/opentracing-contrib/go-grpc v0.0.0-20191001143057-db30781987df h1:vdYtBU6zvL7v+Tr+0xFM/qhahw/EvY8DMMunZHKH6eE= +github.com/opentracing-contrib/go-grpc v0.0.0-20191001143057-db30781987df/go.mod h1:DYR5Eij8rJl8h7gblRrOZ8g0kW1umSpKqYIBTgeDtLo= github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9 h1:QsgXACQhd9QJhEmRumbsMQQvBtmdS0mafoVEBplWXEg= github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9/go.mod h1:PLldrQSroqzH70Xl+1DQcGnefIbqsKR7UDaiux3zV+w= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= @@ -505,6 +508,7 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190921015927-1a5e07d1ff72/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= @@ -581,6 +585,7 @@ google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEd google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=