From fa3a04ccf32115bf81269ff53ad9fde1614fe913 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 13:57:37 -0800 Subject: [PATCH 1/6] rename `Status` to `StatusService` --- crypto/crypto.go | 1 - crypto/crypto_test.go | 2 +- protos/status/status.pb.go | 235 ++++++++++++++++++++++++++++++------- protos/status/status.proto | 6 + utils/grpc/client.go | 2 +- utils/grpc/status.go | 3 +- 6 files changed, 200 insertions(+), 49 deletions(-) diff --git a/crypto/crypto.go b/crypto/crypto.go index 84c023d..d1186e7 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -155,4 +155,3 @@ func GetPubKeyFromPeerId(pid string) (ic.PubKey, error) { } return pubKey, nil } - diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index b09e4ff..e34fbac 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -7,7 +7,7 @@ import ( ) const ( - KeyString = "CAISIJFNZZd5ZSvi9OlJP/mz/vvUobvlrr2//QN4DzX/EShP" + KeyString = "CAISIJFNZZd5ZSvi9OlJP/mz/vvUobvlrr2//QN4DzX/EShP" EncryptKey = "Tron2theMoon1234" ) diff --git a/protos/status/status.pb.go b/protos/status/status.pb.go index c9aa418..94bb30a 100644 --- a/protos/status/status.pb.go +++ b/protos/status/status.pb.go @@ -388,51 +388,52 @@ func init() { proto.RegisterFile("protos/status/status.proto", fileDescriptor_e9 func init() { golang_proto.RegisterFile("protos/status/status.proto", fileDescriptor_e9255cc60c5ca429) } var fileDescriptor_e9255cc60c5ca429 = []byte{ - // 689 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x4f, 0x14, 0x31, - 0x14, 0xb6, 0x08, 0x03, 0xd3, 0xdd, 0x35, 0xb1, 0x46, 0x9c, 0xac, 0xba, 0x8b, 0xeb, 0x85, 0x03, - 0xce, 0x1a, 0x30, 0x26, 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8, 0xfb, 0x38, 0x05, 0xe1, - 0x96, 0x48, 0xc9, 0x73, 0x82, 0x99, 0x1a, 0xa3, 0x37, 0x10, 0x2a, 0x3c, 0x64, 0x24, 0xe6, 0x38, - 0x27, 0xe6, 0x14, 0x7f, 0xb0, 0x7a, 0x7a, 0xd4, 0x7d, 0x58, 0x64, 0xab, 0xbd, 0xb1, 0xc9, 0x89, - 0x73, 0xc1, 0xa9, 0x12, 0x92, 0xf2, 0x6c, 0x09, 0x33, 0x8a, 0xcb, 0x55, 0xb5, 0x94, 0xd2, 0x32, - 0xc1, 0x32, 0x8d, 0x2b, 0xbe, 0xc7, 0xc5, 0x3b, 0x1e, 0x27, 0x82, 0x55, 0x39, 0x2f, 0x7b, 0x91, - 0x6f, 0x76, 0xdb, 0xc2, 0x39, 0x41, 0x37, 0xe0, 0x2c, 0x17, 0x29, 0x89, 0x69, 0x6a, 0xee, 0xe7, - 0x47, 0x9e, 0x86, 0x1b, 0x29, 0xba, 0x03, 0x9b, 0x43, 0x35, 0x2a, 0xe3, 0x7d, 0x22, 0x4b, 0x2a, - 0xb8, 0xb9, 0xa1, 0x1f, 0x35, 0x34, 0xb7, 0x6b, 0x29, 0x74, 0x17, 0xb6, 0x46, 0x98, 0xb2, 0x4a, - 0x92, 0xb8, 0x10, 0x94, 0xab, 0x60, 0xda, 0xe4, 0x34, 0x1d, 0xb9, 0xad, 0x39, 0xf4, 0x0c, 0x36, - 0xb5, 0x8b, 0x71, 0x22, 0x09, 0x56, 0x24, 0x0d, 0x66, 0x16, 0xc0, 0x62, 0x63, 0xb9, 0x1d, 0x5a, - 0xab, 0xc3, 0xda, 0xea, 0xf0, 0x55, 0x6d, 0xf5, 0x60, 0xee, 0xf0, 0xa8, 0x7b, 0xe9, 0xc3, 0x97, - 0x2e, 0x88, 0x1a, 0x5a, 0xb9, 0x66, 0x85, 0xbd, 0xef, 0x00, 0xfa, 0xda, 0x93, 0x75, 0x29, 0x85, - 0x44, 0xd1, 0x5f, 0x2c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0x81, 0x5f, 0xa6, 0xb0, 0x3d, - 0xff, 0x87, 0xa3, 0xeb, 0x7a, 0xaa, 0xd1, 0x63, 0xd8, 0x5a, 0x13, 0x8c, 0x91, 0x44, 0xb9, 0x41, - 0x42, 0xb5, 0xfe, 0x7c, 0xb8, 0x2e, 0x14, 0x3f, 0x82, 0x4d, 0x27, 0xb6, 0x1d, 0x77, 0xf5, 0x67, - 0xad, 0xa1, 0x2e, 0x92, 0x0e, 0x9e, 0x1e, 0x1e, 0x77, 0xc0, 0xe7, 0xe3, 0x0e, 0xf8, 0x7a, 0xdc, - 0x01, 0x9f, 0x4e, 0x3a, 0xe0, 0xe0, 0xa4, 0x03, 0x0e, 0x4f, 0x3a, 0x00, 0x5e, 0xa1, 0x22, 0xd4, - 0x23, 0xe4, 0xf6, 0x1a, 0x34, 0x6c, 0xa5, 0xdb, 0x5a, 0xbf, 0x0d, 0xde, 0xba, 0xff, 0xda, 0xd0, - 0x33, 0x1b, 0xae, 0xfc, 0x08, 0x00, 0x00, 0xff, 0xff, 0x1b, 0xe5, 0x9c, 0xbb, 0x04, 0x05, 0x00, - 0x00, + // 706 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0xcf, 0x6f, 0xd3, 0x30, + 0x14, 0xc6, 0x63, 0xeb, 0x16, 0xb7, 0x45, 0xc2, 0x88, 0x11, 0x15, 0x68, 0x47, 0xb9, 0xec, 0x30, + 0x5a, 0xd4, 0x21, 0x24, 0x86, 0x04, 0x52, 0xa7, 0x09, 0x26, 0xc6, 0x34, 0xa5, 0x30, 0x09, 0x2e, + 0x91, 0x9b, 0xbc, 0xa6, 0xd6, 0x12, 0x3b, 0x72, 0x9c, 0xa2, 0xf2, 0x57, 0xc0, 0x8d, 0x3f, 0x67, + 0x37, 0x76, 0xe4, 0x2f, 0x18, 0x68, 0x3b, 0x71, 0xdd, 0x8d, 0x1b, 0xb2, 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0x5c, 0x2b, 0xc8, 0xb6, 0xe3, + 0x2e, 0xff, 0xc8, 0x35, 0xd0, 0x79, 0xd4, 0xde, 0x47, 0x84, 0xeb, 0x56, 0xc2, 0x00, 0xe4, 0x84, + 0x05, 0xf0, 0xbf, 0x2a, 0xe9, 0x3f, 0x3e, 0x38, 0x6a, 0xa2, 0x4f, 0x47, 0x4d, 0xf4, 0xe5, 0xa8, + 0x89, 0x3e, 0x1c, 0x37, 0xd1, 0xfe, 0x71, 0x13, 0x1d, 0x1c, 0x37, 0x11, 0xbe, 0xc4, 0x44, 0x47, + 0x3f, 0x06, 0xc5, 0x5a, 0xfd, 0xaa, 0x15, 0xbc, 0xa3, 0xf9, 0x3b, 0xe8, 0x75, 0xf1, 0x42, 0x0f, + 0x2b, 0x66, 0xc1, 0xd5, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x13, 0xfb, 0x08, 0xce, 0x05, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -587,6 +588,150 @@ var _Status_serviceDesc = grpc.ServiceDesc{ Metadata: "protos/status/status.proto", } +// StatusServiceClient is the client API for StatusService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type StatusServiceClient interface { + UpdateMetrics(ctx context.Context, in *SignedMetrics, opts ...grpc.CallOption) (*types.Empty, error) + CollectHealth(ctx context.Context, in *NodeHealth, opts ...grpc.CallOption) (*types.Empty, error) + CollectError(ctx context.Context, in *NodeError, opts ...grpc.CallOption) (*types.Empty, error) +} + +type statusServiceClient struct { + cc *grpc.ClientConn +} + +func NewStatusServiceClient(cc *grpc.ClientConn) StatusServiceClient { + return &statusServiceClient{cc} +} + +func (c *statusServiceClient) UpdateMetrics(ctx context.Context, in *SignedMetrics, opts ...grpc.CallOption) (*types.Empty, error) { + out := new(types.Empty) + err := c.cc.Invoke(ctx, "/status.StatusService/UpdateMetrics", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *statusServiceClient) CollectHealth(ctx context.Context, in *NodeHealth, opts ...grpc.CallOption) (*types.Empty, error) { + out := new(types.Empty) + err := c.cc.Invoke(ctx, "/status.StatusService/CollectHealth", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *statusServiceClient) CollectError(ctx context.Context, in *NodeError, opts ...grpc.CallOption) (*types.Empty, error) { + out := new(types.Empty) + err := c.cc.Invoke(ctx, "/status.StatusService/CollectError", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// StatusServiceServer is the server API for StatusService service. +type StatusServiceServer interface { + UpdateMetrics(context.Context, *SignedMetrics) (*types.Empty, error) + CollectHealth(context.Context, *NodeHealth) (*types.Empty, error) + CollectError(context.Context, *NodeError) (*types.Empty, error) +} + +// UnimplementedStatusServiceServer can be embedded to have forward compatible implementations. +type UnimplementedStatusServiceServer struct { +} + +func (*UnimplementedStatusServiceServer) UpdateMetrics(ctx context.Context, req *SignedMetrics) (*types.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMetrics not implemented") +} +func (*UnimplementedStatusServiceServer) CollectHealth(ctx context.Context, req *NodeHealth) (*types.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method CollectHealth not implemented") +} +func (*UnimplementedStatusServiceServer) CollectError(ctx context.Context, req *NodeError) (*types.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method CollectError not implemented") +} + +func RegisterStatusServiceServer(s *grpc.Server, srv StatusServiceServer) { + s.RegisterService(&_StatusService_serviceDesc, srv) +} + +func _StatusService_UpdateMetrics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SignedMetrics) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StatusServiceServer).UpdateMetrics(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/status.StatusService/UpdateMetrics", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StatusServiceServer).UpdateMetrics(ctx, req.(*SignedMetrics)) + } + return interceptor(ctx, in, info, handler) +} + +func _StatusService_CollectHealth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NodeHealth) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StatusServiceServer).CollectHealth(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/status.StatusService/CollectHealth", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StatusServiceServer).CollectHealth(ctx, req.(*NodeHealth)) + } + return interceptor(ctx, in, info, handler) +} + +func _StatusService_CollectError_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NodeError) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StatusServiceServer).CollectError(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/status.StatusService/CollectError", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StatusServiceServer).CollectError(ctx, req.(*NodeError)) + } + return interceptor(ctx, in, info, handler) +} + +var _StatusService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "status.StatusService", + HandlerType: (*StatusServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateMetrics", + Handler: _StatusService_UpdateMetrics_Handler, + }, + { + MethodName: "CollectHealth", + Handler: _StatusService_CollectHealth_Handler, + }, + { + MethodName: "CollectError", + Handler: _StatusService_CollectError_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "protos/status/status.proto", +} + func (m *SignedMetrics) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) diff --git a/protos/status/status.proto b/protos/status/status.proto index 2938165..b07be66 100644 --- a/protos/status/status.proto +++ b/protos/status/status.proto @@ -26,6 +26,12 @@ service Status { rpc CollectError(NodeError) returns (google.protobuf.Empty); } +service StatusService { + rpc UpdateMetrics(SignedMetrics) returns (google.protobuf.Empty); + rpc CollectHealth(NodeHealth) returns (google.protobuf.Empty); + rpc CollectError(NodeError) returns (google.protobuf.Empty); +} + message SignedMetrics { bytes public_key = 1; bytes signature = 2; diff --git a/utils/grpc/client.go b/utils/grpc/client.go index 5e32cf2..962d669 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -48,7 +48,7 @@ func (g *ClientBuilder) doWithContext(ctx context.Context, f interface{}) error } switch v := f.(type) { case func(context.Context, status.StatusClient) error: - return v(ctx, status.NewStatusClient(conn)) + return v(ctx, status.NewStatusServiceClient(conn)) case func(context.Context, hub.HubQueryClient) error: return v(ctx, hub.NewHubQueryClient(conn)) case func(context.Context, guard.GuardServiceClient) error: diff --git a/utils/grpc/status.go b/utils/grpc/status.go index fdb77f2..692ef88 100644 --- a/utils/grpc/status.go +++ b/utils/grpc/status.go @@ -13,6 +13,7 @@ type StatusClientBuilder struct { ClientBuilder } -func (g *StatusClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, client status.StatusClient) error) error { +func (g *StatusClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, + client status.StatusServiceClient) error) error { return g.doWithContext(ctx, f) } From c86fd6a220407a7fc9ffd26865757dc1f05efb96 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 13:59:11 -0800 Subject: [PATCH 2/6] rename `HubQuery` to `HubQueryService` --- protos/hub/hub.pb.go | 191 ++++++++++++++++++++++--------------------- protos/hub/hub.proto | 2 +- utils/grpc/client.go | 4 +- utils/grpc/hub.go | 3 +- 4 files changed, 101 insertions(+), 99 deletions(-) diff --git a/protos/hub/hub.pb.go b/protos/hub/hub.pb.go index 02006bf..874413f 100644 --- a/protos/hub/hub.pb.go +++ b/protos/hub/hub.pb.go @@ -825,73 +825,74 @@ func init() { proto.RegisterFile("protos/hub/hub.proto", fileDescriptor_c704b599 func init() { golang_proto.RegisterFile("protos/hub/hub.proto", fileDescriptor_c704b5990190a69f) } var fileDescriptor_c704b5990190a69f = []byte{ - // 1053 bytes of a gzipped FileDescriptorProto + // 1061 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x4f, 0x23, 0x47, 0x10, 0xdd, 0x36, 0x06, 0xec, 0xf2, 0x77, 0x2f, 0xcb, 0xce, 0x7a, 0x25, 0xe3, 0x58, 0x59, 0xc5, - 0xbb, 0xd9, 0x98, 0x88, 0x48, 0x1b, 0x29, 0x37, 0x0c, 0x0e, 0x20, 0x41, 0x20, 0x6d, 0xe0, 0x90, - 0xcb, 0xa8, 0xed, 0x69, 0xcc, 0x08, 0x7b, 0x7a, 0x76, 0xba, 0x87, 0x55, 0xf6, 0x57, 0xe4, 0x98, - 0x9f, 0x93, 0x23, 0xc7, 0x28, 0x52, 0xae, 0x49, 0x04, 0x97, 0x9c, 0xf2, 0x1b, 0xa2, 0xea, 0xf9, - 0xb0, 0x0d, 0x8e, 0x94, 0x8d, 0x72, 0x40, 0xea, 0x7a, 0xf5, 0xaa, 0xfc, 0xaa, 0xbb, 0xe7, 0x35, - 0xb0, 0xe6, 0x07, 0x52, 0x4b, 0xb5, 0x79, 0x19, 0x0e, 0xf0, 0xaf, 0x63, 0x42, 0xba, 0x74, 0x19, - 0x0e, 0xea, 0x9f, 0x8f, 0x5c, 0x8d, 0xd0, 0x50, 0x4e, 0x36, 0x75, 0x20, 0xbd, 0xcf, 0x42, 0xb5, - 0x69, 0xd2, 0x83, 0xf0, 0x62, 0x73, 0x24, 0x47, 0xd2, 0x04, 0x66, 0x15, 0x95, 0xd5, 0x37, 0x46, - 0x52, 0x8e, 0xc6, 0x62, 0xca, 0xd2, 0xee, 0x44, 0x28, 0xcd, 0x27, 0x7e, 0x44, 0x68, 0x7d, 0x05, - 0x85, 0xbe, 0xd0, 0xda, 0x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 0x05, 0xa5, 0x3d, 0xae, 0xd2, 0x47, 0x94, 0xd6, 0xe7, 0x9e, 0x5c, 0x93, 0xbf, 0x6d, + 0x36, 0xee, 0x21, 0x32, 0xa0, 0x2f, 0xa1, 0xb0, 0xc7, 0x95, 0x36, 0x59, 0x5a, 0x99, 0x3e, 0x00, + 0xc8, 0xae, 0xce, 0x86, 0x32, 0xe8, 0xbf, 0xb9, 0xb9, 0x6d, 0x91, 0x9f, 0x6f, 0x5b, 0xe4, 0x8f, + 0xdb, 0x16, 0xf9, 0xf1, 0xae, 0x45, 0x7e, 0xba, 0x6b, 0x91, 0x9b, 0xbb, 0x16, 0x81, 0x92, 0x2b, + 0x7a, 0x68, 0x38, 0x58, 0xd0, 0x2f, 0xec, 0x47, 0xa3, 0x13, 0xf4, 0xbc, 0x13, 0xf2, 0x1d, 0xfe, + 0xf7, 0x34, 0x5a, 0xd1, 0x0e, 0xf8, 0xc5, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x26, 0xe9, 0xbf, + 0xa1, 0x61, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -902,108 +903,108 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// HubQueryClient is the client API for HubQuery service. +// HubQueryServiceClient is the client API for HubQueryService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type HubQueryClient interface { +type HubQueryServiceClient interface { GetSettings(ctx context.Context, in *SettingsReq, opts ...grpc.CallOption) (*SettingsResp, error) GetHosts(ctx context.Context, in *HostsReq, opts ...grpc.CallOption) (*HostsResp, error) } -type hubQueryClient struct { +type hubQueryServiceClient struct { cc *grpc.ClientConn } -func NewHubQueryClient(cc *grpc.ClientConn) HubQueryClient { - return &hubQueryClient{cc} +func NewHubQueryServiceClient(cc *grpc.ClientConn) HubQueryServiceClient { + return &hubQueryServiceClient{cc} } -func (c *hubQueryClient) GetSettings(ctx context.Context, in *SettingsReq, opts ...grpc.CallOption) (*SettingsResp, error) { +func (c *hubQueryServiceClient) GetSettings(ctx context.Context, in *SettingsReq, opts ...grpc.CallOption) (*SettingsResp, error) { out := new(SettingsResp) - err := c.cc.Invoke(ctx, "/hub.HubQuery/GetSettings", in, out, opts...) + err := c.cc.Invoke(ctx, "/hub.HubQueryService/GetSettings", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *hubQueryClient) GetHosts(ctx context.Context, in *HostsReq, opts ...grpc.CallOption) (*HostsResp, error) { +func (c *hubQueryServiceClient) GetHosts(ctx context.Context, in *HostsReq, opts ...grpc.CallOption) (*HostsResp, error) { out := new(HostsResp) - err := c.cc.Invoke(ctx, "/hub.HubQuery/GetHosts", in, out, opts...) + err := c.cc.Invoke(ctx, "/hub.HubQueryService/GetHosts", in, out, opts...) if err != nil { return nil, err } return out, nil } -// HubQueryServer is the server API for HubQuery service. -type HubQueryServer interface { +// HubQueryServiceServer is the server API for HubQueryService service. +type HubQueryServiceServer interface { GetSettings(context.Context, *SettingsReq) (*SettingsResp, error) GetHosts(context.Context, *HostsReq) (*HostsResp, error) } -// UnimplementedHubQueryServer can be embedded to have forward compatible implementations. -type UnimplementedHubQueryServer struct { +// UnimplementedHubQueryServiceServer can be embedded to have forward compatible implementations. +type UnimplementedHubQueryServiceServer struct { } -func (*UnimplementedHubQueryServer) GetSettings(ctx context.Context, req *SettingsReq) (*SettingsResp, error) { +func (*UnimplementedHubQueryServiceServer) GetSettings(ctx context.Context, req *SettingsReq) (*SettingsResp, error) { return nil, status.Errorf(codes.Unimplemented, "method GetSettings not implemented") } -func (*UnimplementedHubQueryServer) GetHosts(ctx context.Context, req *HostsReq) (*HostsResp, error) { +func (*UnimplementedHubQueryServiceServer) GetHosts(ctx context.Context, req *HostsReq) (*HostsResp, error) { return nil, status.Errorf(codes.Unimplemented, "method GetHosts not implemented") } -func RegisterHubQueryServer(s *grpc.Server, srv HubQueryServer) { - s.RegisterService(&_HubQuery_serviceDesc, srv) +func RegisterHubQueryServiceServer(s *grpc.Server, srv HubQueryServiceServer) { + s.RegisterService(&_HubQueryService_serviceDesc, srv) } -func _HubQuery_GetSettings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _HubQueryService_GetSettings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SettingsReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(HubQueryServer).GetSettings(ctx, in) + return srv.(HubQueryServiceServer).GetSettings(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/hub.HubQuery/GetSettings", + FullMethod: "/hub.HubQueryService/GetSettings", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(HubQueryServer).GetSettings(ctx, req.(*SettingsReq)) + return srv.(HubQueryServiceServer).GetSettings(ctx, req.(*SettingsReq)) } return interceptor(ctx, in, info, handler) } -func _HubQuery_GetHosts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _HubQueryService_GetHosts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(HostsReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(HubQueryServer).GetHosts(ctx, in) + return srv.(HubQueryServiceServer).GetHosts(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/hub.HubQuery/GetHosts", + FullMethod: "/hub.HubQueryService/GetHosts", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(HubQueryServer).GetHosts(ctx, req.(*HostsReq)) + return srv.(HubQueryServiceServer).GetHosts(ctx, req.(*HostsReq)) } return interceptor(ctx, in, info, handler) } -var _HubQuery_serviceDesc = grpc.ServiceDesc{ - ServiceName: "hub.HubQuery", - HandlerType: (*HubQueryServer)(nil), +var _HubQueryService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "hub.HubQueryService", + HandlerType: (*HubQueryServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetSettings", - Handler: _HubQuery_GetSettings_Handler, + Handler: _HubQueryService_GetSettings_Handler, }, { MethodName: "GetHosts", - Handler: _HubQuery_GetHosts_Handler, + Handler: _HubQueryService_GetHosts_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/protos/hub/hub.proto b/protos/hub/hub.proto index 20626b2..af57a2d 100644 --- a/protos/hub/hub.proto +++ b/protos/hub/hub.proto @@ -19,7 +19,7 @@ option java_package = "io.btfs.hub"; import "github.com/tron-us/protobuf/gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -service HubQuery { +service HubQueryService { rpc GetSettings(SettingsReq) returns (SettingsResp); rpc GetHosts(HostsReq) returns (HostsResp); } diff --git a/utils/grpc/client.go b/utils/grpc/client.go index 962d669..3a0fe16 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -49,8 +49,8 @@ func (g *ClientBuilder) doWithContext(ctx context.Context, f interface{}) error switch v := f.(type) { case func(context.Context, status.StatusClient) error: return v(ctx, status.NewStatusServiceClient(conn)) - case func(context.Context, hub.HubQueryClient) error: - return v(ctx, hub.NewHubQueryClient(conn)) + case func(context.Context, hub.HubQueryServiceClient) error: + return v(ctx, hub.NewHubQueryServiceClient(conn)) case func(context.Context, guard.GuardServiceClient) error: return v(ctx, guard.NewGuardServiceClient(conn)) case func(context.Context, escrow.EscrowServiceClient) error: diff --git a/utils/grpc/hub.go b/utils/grpc/hub.go index 9fcb33e..7db6f14 100644 --- a/utils/grpc/hub.go +++ b/utils/grpc/hub.go @@ -13,6 +13,7 @@ type HubQueryClientBuilder struct { ClientBuilder } -func (g *HubQueryClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, client hub.HubQueryClient) error) error { +func (g *HubQueryClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, + client hub.HubQueryServiceClient) error) error { return g.doWithContext(ctx, f) } From 8ff19506c0e4736ebce21ef0de0cb77830f547fe Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 14:05:49 -0800 Subject: [PATCH 3/6] add runtime client --- utils/grpc/client.go | 27 +++++++++++++++------------ utils/grpc/escrow.go | 6 ++++-- utils/grpc/guard.go | 6 ++++-- utils/grpc/hub.go | 5 +++-- utils/grpc/runtime.go | 20 ++++++++++++++++++++ utils/grpc/status.go | 5 +++-- 6 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 utils/grpc/runtime.go diff --git a/utils/grpc/client.go b/utils/grpc/client.go index 3a0fe16..65b24ab 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -11,10 +11,11 @@ import ( "strings" "time" - "github.com/tron-us/go-btfs-common/protos/escrow" - "github.com/tron-us/go-btfs-common/protos/guard" - "github.com/tron-us/go-btfs-common/protos/hub" - "github.com/tron-us/go-btfs-common/protos/status" + escrowpb "github.com/tron-us/go-btfs-common/protos/escrow" + guardpb "github.com/tron-us/go-btfs-common/protos/guard" + hubpb "github.com/tron-us/go-btfs-common/protos/hub" + sharedpb "github.com/tron-us/go-btfs-common/protos/shared" + statuspb "github.com/tron-us/go-btfs-common/protos/status" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" @@ -47,14 +48,16 @@ func (g *ClientBuilder) doWithContext(ctx context.Context, f interface{}) error return errors.New("failed to get connection") } switch v := f.(type) { - case func(context.Context, status.StatusClient) error: - return v(ctx, status.NewStatusServiceClient(conn)) - case func(context.Context, hub.HubQueryServiceClient) error: - return v(ctx, hub.NewHubQueryServiceClient(conn)) - case func(context.Context, guard.GuardServiceClient) error: - return v(ctx, guard.NewGuardServiceClient(conn)) - case func(context.Context, escrow.EscrowServiceClient) error: - return v(ctx, escrow.NewEscrowServiceClient(conn)) + case func(context.Context, statuspb.StatusClient) error: + return v(ctx, statuspb.NewStatusServiceClient(conn)) + case func(context.Context, hubpb.HubQueryServiceClient) error: + return v(ctx, hubpb.NewHubQueryServiceClient(conn)) + case func(context.Context, guardpb.GuardServiceClient) error: + return v(ctx, guardpb.NewGuardServiceClient(conn)) + case func(context.Context, escrowpb.EscrowServiceClient) error: + return v(ctx, escrowpb.NewEscrowServiceClient(conn)) + case func(ctx context.Context, client sharedpb.RuntimeServiceClient) error: + return v(ctx, sharedpb.NewRuntimeServiceClient(conn)) default: return fmt.Errorf("illegal function: %T", f) } diff --git a/utils/grpc/escrow.go b/utils/grpc/escrow.go index 8f38ad1..f520789 100644 --- a/utils/grpc/escrow.go +++ b/utils/grpc/escrow.go @@ -2,7 +2,8 @@ package grpc import ( "context" - "github.com/tron-us/go-btfs-common/protos/escrow" + + escrowpb "github.com/tron-us/go-btfs-common/protos/escrow" ) func EscrowClient(addr string) *EscrowClientBuilder { @@ -13,6 +14,7 @@ type EscrowClientBuilder struct { ClientBuilder } -func (g *EscrowClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, client escrow.EscrowServiceClient) error) error { +func (g *EscrowClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, + client escrowpb.EscrowServiceClient) error) error { return g.doWithContext(ctx, f) } diff --git a/utils/grpc/guard.go b/utils/grpc/guard.go index ce1c345..068e206 100644 --- a/utils/grpc/guard.go +++ b/utils/grpc/guard.go @@ -2,7 +2,8 @@ package grpc import ( "context" - "github.com/tron-us/go-btfs-common/protos/guard" + + guardpb "github.com/tron-us/go-btfs-common/protos/guard" ) func GuardClient(addr string) *GuardClientBuilder { @@ -13,6 +14,7 @@ type GuardClientBuilder struct { ClientBuilder } -func (g *GuardClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, client guard.GuardServiceClient) error) error { +func (g *GuardClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, + client guardpb.GuardServiceClient) error) error { return g.doWithContext(ctx, f) } diff --git a/utils/grpc/hub.go b/utils/grpc/hub.go index 7db6f14..548292f 100644 --- a/utils/grpc/hub.go +++ b/utils/grpc/hub.go @@ -2,7 +2,8 @@ package grpc import ( "context" - "github.com/tron-us/go-btfs-common/protos/hub" + + hubpb "github.com/tron-us/go-btfs-common/protos/hub" ) func HubQueryClient(addr string) *HubQueryClientBuilder { @@ -14,6 +15,6 @@ type HubQueryClientBuilder struct { } func (g *HubQueryClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, - client hub.HubQueryServiceClient) error) error { + client hubpb.HubQueryServiceClient) error) error { return g.doWithContext(ctx, f) } diff --git a/utils/grpc/runtime.go b/utils/grpc/runtime.go new file mode 100644 index 0000000..6db820b --- /dev/null +++ b/utils/grpc/runtime.go @@ -0,0 +1,20 @@ +package grpc + +import ( + "context" + + sharedpb "github.com/tron-us/go-btfs-common/protos/shared" +) + +func RuntimeClient(addr string) *RuntimeClientBuilder { + return &RuntimeClientBuilder{builder(addr)} +} + +type RuntimeClientBuilder struct { + ClientBuilder +} + +func (g *RuntimeClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, + client sharedpb.RuntimeServiceClient) error) error { + return g.doWithContext(ctx, f) +} diff --git a/utils/grpc/status.go b/utils/grpc/status.go index 692ef88..edb1874 100644 --- a/utils/grpc/status.go +++ b/utils/grpc/status.go @@ -2,7 +2,8 @@ package grpc import ( "context" - "github.com/tron-us/go-btfs-common/protos/status" + + statuspb "github.com/tron-us/go-btfs-common/protos/status" ) func StatusClient(addr string) *StatusClientBuilder { @@ -14,6 +15,6 @@ type StatusClientBuilder struct { } func (g *StatusClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, - client status.StatusServiceClient) error) error { + client statuspb.StatusServiceClient) error) error { return g.doWithContext(ctx, f) } From a0a813abcf9eef8bc4a846b55ec302dac23b7316 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 14:09:36 -0800 Subject: [PATCH 4/6] add health-check-client --- utils/grpc/client.go | 3 +++ utils/grpc/health_check.go | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 utils/grpc/health_check.go diff --git a/utils/grpc/client.go b/utils/grpc/client.go index 65b24ab..db53812 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "errors" "fmt" + "google.golang.org/grpc/health/grpc_health_v1" "net/url" "regexp" "strconv" @@ -58,6 +59,8 @@ func (g *ClientBuilder) doWithContext(ctx context.Context, f interface{}) error return v(ctx, escrowpb.NewEscrowServiceClient(conn)) case func(ctx context.Context, client sharedpb.RuntimeServiceClient) error: return v(ctx, sharedpb.NewRuntimeServiceClient(conn)) + case func(ctx context.Context, client grpc_health_v1.HealthClient) error: + return v(ctx, grpc_health_v1.NewHealthClient(conn)) default: return fmt.Errorf("illegal function: %T", f) } diff --git a/utils/grpc/health_check.go b/utils/grpc/health_check.go new file mode 100644 index 0000000..dac7676 --- /dev/null +++ b/utils/grpc/health_check.go @@ -0,0 +1,19 @@ +package grpc + +import ( + "context" + "google.golang.org/grpc/health/grpc_health_v1" +) + +func HealthCheckClient(addr string) *HealthCheckClientBuilder { + return &HealthCheckClientBuilder{builder(addr)} +} + +type HealthCheckClientBuilder struct { + ClientBuilder +} + +func (g *HealthCheckClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, + client grpc_health_v1.HealthClient) error) error { + return g.doWithContext(ctx, f) +} From 488e5bad8945df48b108aeb061e432d188e284a2 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 14:50:58 -0800 Subject: [PATCH 5/6] rename statusclient to statusserviceclient --- utils/grpc/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/grpc/client.go b/utils/grpc/client.go index db53812..dc1962f 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -49,7 +49,7 @@ func (g *ClientBuilder) doWithContext(ctx context.Context, f interface{}) error return errors.New("failed to get connection") } switch v := f.(type) { - case func(context.Context, statuspb.StatusClient) error: + case func(context.Context, statuspb.StatusServiceClient) error: return v(ctx, statuspb.NewStatusServiceClient(conn)) case func(context.Context, hubpb.HubQueryServiceClient) error: return v(ctx, hubpb.NewHubQueryServiceClient(conn)) From 98cb69bae96d6e5c83c9f3f4439d1102d0675430 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 14:53:24 -0800 Subject: [PATCH 6/6] refactor imports --- utils/grpc/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/grpc/client.go b/utils/grpc/client.go index dc1962f..05f070a 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "errors" "fmt" - "google.golang.org/grpc/health/grpc_health_v1" "net/url" "regexp" "strconv" @@ -21,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/health/grpc_health_v1" ) const (