阶段性提交

This commit is contained in:
GoEdgeLab
2020-07-21 17:27:00 +08:00
commit a39aeb54c8
38 changed files with 2505 additions and 0 deletions

68
internal/apis/api_node.go Normal file
View File

@@ -0,0 +1,68 @@
package apis
import (
"errors"
"github.com/TeaOSLab/EdgeAPI/internal/configs"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/dns"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/log"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/monitor"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/node"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/provider"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/stat"
"github.com/TeaOSLab/EdgeAPI/internal/rpc/user"
"github.com/iwind/TeaGo/logs"
"google.golang.org/grpc"
"net"
"os"
"strconv"
)
var sharedAPIConfig *configs.APIConfig = nil
type APINode struct {
}
func NewAPINode() *APINode {
return &APINode{}
}
func (this *APINode) Start() {
logs.Println("[API]start api node, pid: " + strconv.Itoa(os.Getpid()))
config, err := configs.SharedAPIConfig()
if err != nil {
logs.Println("[API]start failed: " + err.Error())
return
}
sharedAPIConfig = config
// 监听RPC服务
logs.Println("[API]start rpc: " + config.RPC.Listen)
err = this.listenRPC()
if err != nil {
logs.Println(err.Error())
return
}
}
// 启动RPC监听
func (this *APINode) listenRPC() error {
listener, err := net.Listen("tcp", sharedAPIConfig.RPC.Listen)
if err != nil {
return errors.New("[API]listen rpc failed: " + err.Error())
}
rpcServer := grpc.NewServer()
dns.RegisterServiceServer(rpcServer, &dns.Service{})
log.RegisterServiceServer(rpcServer, &log.Service{})
monitor.RegisterServiceServer(rpcServer, &monitor.Service{})
node.RegisterServiceServer(rpcServer, &node.Service{})
provider.RegisterServiceServer(rpcServer, &provider.Service{})
stat.RegisterServiceServer(rpcServer, &stat.Service{})
user.RegisterServiceServer(rpcServer, &user.Service{})
err = rpcServer.Serve(listener)
if err != nil {
return errors.New("[API]start rpc failed: " + err.Error())
}
return nil
}

View File

@@ -0,0 +1,38 @@
package configs
import (
"github.com/go-yaml/yaml"
"github.com/iwind/TeaGo/Tea"
"io/ioutil"
)
var sharedAPIConfig *APIConfig = nil
type APIConfig struct {
RPC struct {
Listen string `yaml:"listen"`
} `yaml:"rpc"`
}
func SharedAPIConfig() (*APIConfig, error) {
sharedLocker.Lock()
defer sharedLocker.Unlock()
if sharedAPIConfig != nil {
return sharedAPIConfig, nil
}
data, err := ioutil.ReadFile(Tea.ConfigFile("api.yaml"))
if err != nil {
return nil, err
}
config := &APIConfig{}
err = yaml.Unmarshal(data, config)
if err != nil {
return nil, err
}
sharedAPIConfig = config
return config, nil
}

View File

@@ -0,0 +1,14 @@
package configs
import (
_ "github.com/iwind/TeaGo/bootstrap"
"testing"
)
func TestSharedAPIConfig(t *testing.T) {
config, err := SharedAPIConfig()
if err != nil {
t.Fatal(err)
}
t.Log(config)
}

View File

@@ -0,0 +1,5 @@
package configs
import "sync"
var sharedLocker = &sync.RWMutex{}

View File

@@ -0,0 +1,279 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: admin/service.proto
package admin
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type LoginRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *LoginRequest) Reset() {
*x = LoginRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_admin_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginRequest) ProtoMessage() {}
func (x *LoginRequest) ProtoReflect() protoreflect.Message {
mi := &file_admin_service_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead.
func (*LoginRequest) Descriptor() ([]byte, []int) {
return file_admin_service_proto_rawDescGZIP(), []int{0}
}
type LoginResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *LoginResponse) Reset() {
*x = LoginResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_admin_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginResponse) ProtoMessage() {}
func (x *LoginResponse) ProtoReflect() protoreflect.Message {
mi := &file_admin_service_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead.
func (*LoginResponse) Descriptor() ([]byte, []int) {
return file_admin_service_proto_rawDescGZIP(), []int{1}
}
var File_admin_service_proto protoreflect.FileDescriptor
var file_admin_service_proto_rawDesc = []byte{
0x0a, 0x13, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x0e, 0x0a, 0x0c,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0f, 0x0a, 0x0d,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x3f, 0x0a,
0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69,
0x6e, 0x12, 0x13, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x4c,
0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09,
0x5a, 0x07, 0x2e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
file_admin_service_proto_rawDescOnce sync.Once
file_admin_service_proto_rawDescData = file_admin_service_proto_rawDesc
)
func file_admin_service_proto_rawDescGZIP() []byte {
file_admin_service_proto_rawDescOnce.Do(func() {
file_admin_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_admin_service_proto_rawDescData)
})
return file_admin_service_proto_rawDescData
}
var file_admin_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_admin_service_proto_goTypes = []interface{}{
(*LoginRequest)(nil), // 0: admin.LoginRequest
(*LoginResponse)(nil), // 1: admin.LoginResponse
}
var file_admin_service_proto_depIdxs = []int32{
0, // 0: admin.Service.login:input_type -> admin.LoginRequest
1, // 1: admin.Service.login:output_type -> admin.LoginResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_admin_service_proto_init() }
func file_admin_service_proto_init() {
if File_admin_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_admin_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_admin_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_admin_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_admin_service_proto_goTypes,
DependencyIndexes: file_admin_service_proto_depIdxs,
MessageInfos: file_admin_service_proto_msgTypes,
}.Build()
File_admin_service_proto = out.File
file_admin_service_proto_rawDesc = nil
file_admin_service_proto_goTypes = nil
file_admin_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
func (c *serviceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
out := new(LoginResponse)
err := c.cc.Invoke(ctx, "/admin.Service/login", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
Login(context.Context, *LoginRequest) (*LoginResponse, error)
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func (*UnimplementedServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
func _Service_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ServiceServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/admin.Service/Login",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ServiceServer).Login(ctx, req.(*LoginRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "admin.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "login",
Handler: _Service_Login_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "admin/service.proto",
}

View File

@@ -0,0 +1,18 @@
syntax = "proto3";
package admin;
option go_package = "./admin";
service Service {
rpc login (LoginRequest) returns (LoginResponse) {
}
}
message LoginRequest {
}
message LoginResponse {
}

View File

@@ -0,0 +1,4 @@
package dns
type Service struct {
}

View File

@@ -0,0 +1,111 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: dns/service.proto
package dns
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
var File_dns_service_proto protoreflect.FileDescriptor
var file_dns_service_proto_rawDesc = []byte{
0x0a, 0x11, 0x64, 0x6e, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x03, 0x64, 0x6e, 0x73, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x64, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var file_dns_service_proto_goTypes = []interface{}{}
var file_dns_service_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_dns_service_proto_init() }
func file_dns_service_proto_init() {
if File_dns_service_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_dns_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_dns_service_proto_goTypes,
DependencyIndexes: file_dns_service_proto_depIdxs,
}.Build()
File_dns_service_proto = out.File
file_dns_service_proto_rawDesc = nil
file_dns_service_proto_goTypes = nil
file_dns_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "dns.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},
Metadata: "dns/service.proto",
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package dns;
option go_package = "./dns";
service Service {
}

View File

@@ -0,0 +1,4 @@
package log
type Service struct {
}

View File

@@ -0,0 +1,111 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: log/service.proto
package log
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
var File_log_service_proto protoreflect.FileDescriptor
var file_log_service_proto_rawDesc = []byte{
0x0a, 0x11, 0x6c, 0x6f, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x03, 0x6c, 0x6f, 0x67, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x6c, 0x6f, 0x67, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var file_log_service_proto_goTypes = []interface{}{}
var file_log_service_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_log_service_proto_init() }
func file_log_service_proto_init() {
if File_log_service_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_log_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_log_service_proto_goTypes,
DependencyIndexes: file_log_service_proto_depIdxs,
}.Build()
File_log_service_proto = out.File
file_log_service_proto_rawDesc = nil
file_log_service_proto_goTypes = nil
file_log_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "log.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},
Metadata: "log/service.proto",
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package log;
option go_package = "./log";
service Service {
}

View File

@@ -0,0 +1,4 @@
package monitor
type Service struct {
}

View File

@@ -0,0 +1,111 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: monitor/service.proto
package monitor
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
var File_monitor_service_proto protoreflect.FileDescriptor
var file_monitor_service_proto_rawDesc = []byte{
0x0a, 0x15, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72,
0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x2e,
0x2f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_monitor_service_proto_goTypes = []interface{}{}
var file_monitor_service_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_monitor_service_proto_init() }
func file_monitor_service_proto_init() {
if File_monitor_service_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_monitor_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_monitor_service_proto_goTypes,
DependencyIndexes: file_monitor_service_proto_depIdxs,
}.Build()
File_monitor_service_proto = out.File
file_monitor_service_proto_rawDesc = nil
file_monitor_service_proto_goTypes = nil
file_monitor_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "monitor.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},
Metadata: "monitor/service.proto",
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package monitor;
option go_package = "./monitor";
service Service {
}

View File

@@ -0,0 +1,14 @@
package node
import (
"context"
"github.com/iwind/TeaGo/logs"
)
type Service struct {
}
func (this *Service) Node(context.Context, *NodeRequest) (*NodeResponse, error) {
logs.Println("you called me")
return &NodeResponse{}, nil
}

View File

@@ -0,0 +1,278 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: node/service.proto
package node
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type NodeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *NodeRequest) Reset() {
*x = NodeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_node_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NodeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NodeRequest) ProtoMessage() {}
func (x *NodeRequest) ProtoReflect() protoreflect.Message {
mi := &file_node_service_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NodeRequest.ProtoReflect.Descriptor instead.
func (*NodeRequest) Descriptor() ([]byte, []int) {
return file_node_service_proto_rawDescGZIP(), []int{0}
}
type NodeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *NodeResponse) Reset() {
*x = NodeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_node_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NodeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NodeResponse) ProtoMessage() {}
func (x *NodeResponse) ProtoReflect() protoreflect.Message {
mi := &file_node_service_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NodeResponse.ProtoReflect.Descriptor instead.
func (*NodeResponse) Descriptor() ([]byte, []int) {
return file_node_service_proto_rawDescGZIP(), []int{1}
}
var File_node_service_proto protoreflect.FileDescriptor
var file_node_service_proto_rawDesc = []byte{
0x0a, 0x12, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x4e, 0x6f,
0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x4e, 0x6f, 0x64,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x3a, 0x0a, 0x07, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x12, 0x11, 0x2e, 0x6e,
0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x12, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_node_service_proto_rawDescOnce sync.Once
file_node_service_proto_rawDescData = file_node_service_proto_rawDesc
)
func file_node_service_proto_rawDescGZIP() []byte {
file_node_service_proto_rawDescOnce.Do(func() {
file_node_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_node_service_proto_rawDescData)
})
return file_node_service_proto_rawDescData
}
var file_node_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_node_service_proto_goTypes = []interface{}{
(*NodeRequest)(nil), // 0: node.NodeRequest
(*NodeResponse)(nil), // 1: node.NodeResponse
}
var file_node_service_proto_depIdxs = []int32{
0, // 0: node.Service.node:input_type -> node.NodeRequest
1, // 1: node.Service.node:output_type -> node.NodeResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_node_service_proto_init() }
func file_node_service_proto_init() {
if File_node_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_node_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NodeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_node_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NodeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_node_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_node_service_proto_goTypes,
DependencyIndexes: file_node_service_proto_depIdxs,
MessageInfos: file_node_service_proto_msgTypes,
}.Build()
File_node_service_proto = out.File
file_node_service_proto_rawDesc = nil
file_node_service_proto_goTypes = nil
file_node_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
Node(ctx context.Context, in *NodeRequest, opts ...grpc.CallOption) (*NodeResponse, error)
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
func (c *serviceClient) Node(ctx context.Context, in *NodeRequest, opts ...grpc.CallOption) (*NodeResponse, error) {
out := new(NodeResponse)
err := c.cc.Invoke(ctx, "/node.Service/node", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
Node(context.Context, *NodeRequest) (*NodeResponse, error)
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func (*UnimplementedServiceServer) Node(context.Context, *NodeRequest) (*NodeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Node not implemented")
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
func _Service_Node_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(NodeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ServiceServer).Node(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/node.Service/Node",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ServiceServer).Node(ctx, req.(*NodeRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "node.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "node",
Handler: _Service_Node_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "node/service.proto",
}

View File

@@ -0,0 +1,19 @@
syntax = "proto3";
package node;
option go_package = "./node";
service Service {
rpc node (NodeRequest) returns (NodeResponse) {
}
}
message NodeRequest {
}
message NodeResponse {
}

View File

@@ -0,0 +1,112 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: provider/provider.proto
package provider
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
var File_provider_provider_proto protoreflect.FileDescriptor
var file_provider_provider_proto_rawDesc = []byte{
0x0a, 0x17, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69,
0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69,
0x64, 0x65, 0x72, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x0c,
0x5a, 0x0a, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var file_provider_provider_proto_goTypes = []interface{}{}
var file_provider_provider_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_provider_provider_proto_init() }
func file_provider_provider_proto_init() {
if File_provider_provider_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_provider_provider_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_provider_provider_proto_goTypes,
DependencyIndexes: file_provider_provider_proto_depIdxs,
}.Build()
File_provider_provider_proto = out.File
file_provider_provider_proto_rawDesc = nil
file_provider_provider_proto_goTypes = nil
file_provider_provider_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "provider.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},
Metadata: "provider/provider.proto",
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package provider;
option go_package = "./provider";
service Service {
}

View File

@@ -0,0 +1,4 @@
package provider
type Service struct {
}

View File

@@ -0,0 +1,4 @@
package stat
type Service struct {
}

View File

@@ -0,0 +1,111 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: stat/service.proto
package stat
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
var File_stat_service_proto protoreflect.FileDescriptor
var file_stat_service_proto_rawDesc = []byte{
0x0a, 0x12, 0x73, 0x74, 0x61, 0x74, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x73, 0x74, 0x61, 0x74, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_stat_service_proto_goTypes = []interface{}{}
var file_stat_service_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_stat_service_proto_init() }
func file_stat_service_proto_init() {
if File_stat_service_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_stat_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_stat_service_proto_goTypes,
DependencyIndexes: file_stat_service_proto_depIdxs,
}.Build()
File_stat_service_proto = out.File
file_stat_service_proto_rawDesc = nil
file_stat_service_proto_goTypes = nil
file_stat_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "stat.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},
Metadata: "stat/service.proto",
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package stat;
option go_package = "./stat";
service Service {
}

View File

@@ -0,0 +1,4 @@
package user
type Service struct {
}

View File

@@ -0,0 +1,111 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: user/service.proto
package user
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
var File_user_service_proto protoreflect.FileDescriptor
var file_user_service_proto_rawDesc = []byte{
0x0a, 0x12, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, 0x09, 0x0a, 0x07, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_user_service_proto_goTypes = []interface{}{}
var file_user_service_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_user_service_proto_init() }
func file_user_service_proto_init() {
if File_user_service_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_user_service_proto_goTypes,
DependencyIndexes: file_user_service_proto_depIdxs,
}.Build()
File_user_service_proto = out.File
file_user_service_proto_rawDesc = nil
file_user_service_proto_goTypes = nil
file_user_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServiceClient is the client API for Service service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServiceClient interface {
}
type serviceClient struct {
cc grpc.ClientConnInterface
}
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
return &serviceClient{cc}
}
// ServiceServer is the server API for Service service.
type ServiceServer interface {
}
// UnimplementedServiceServer can be embedded to have forward compatible implementations.
type UnimplementedServiceServer struct {
}
func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
s.RegisterService(&_Service_serviceDesc, srv)
}
var _Service_serviceDesc = grpc.ServiceDesc{
ServiceName: "user.Service",
HandlerType: (*ServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},
Metadata: "user/service.proto",
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package user;
option go_package = "./user";
service Service {
}

175
internal/tests/grpc_test.go Normal file
View File

@@ -0,0 +1,175 @@
package tests
import (
"context"
"encoding/json"
nodepb "github.com/TeaOSLab/EdgeAPI/internal/rpc/node"
pb "github.com/TeaOSLab/EdgeAPI/internal/tests/helloworld"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"log"
"net"
"runtime"
"strings"
"testing"
"time"
)
type server struct {
}
func (this *server) SayHello(ctx context.Context, request *pb.HelloRequest) (*pb.HelloReply, error) {
md, ok := metadata.FromIncomingContext(ctx)
if ok {
jsonData, _ := json.MarshalIndent(md, "", " ")
log.Print(string(jsonData))
_ = md
}
return &pb.HelloReply{
Message: "Hello, " + request.Name,
}, nil
}
func TestTCPServer(t *testing.T) {
listener, err := net.Listen("tcp", ":8001")
if err != nil {
t.Fatal(err)
}
s := grpc.NewServer()
pb.RegisterGreeterServer(s, &server{})
nodepb.RegisterServiceServer(s, &nodepb.Service{})
err = s.Serve(listener)
if err != nil {
t.Fatal(err)
}
}
func TestTCPClient(t *testing.T) {
conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithInsecure())
if err != nil {
t.Fatal(err)
}
defer func() {
_ = conn.Close()
}()
c := pb.NewGreeterClient(conn)
before := time.Now()
ctx := context.Background()
ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu", "age", "20")
reply, err := c.SayHello(ctx, &pb.HelloRequest{
Name: strings.Repeat("golang", 1),
})
if err != nil {
t.Fatal(err)
}
t.Log(reply.Message)
t.Log(time.Since(before).Seconds()*1000, "ms")
}
func TestTCPClient_Node(t *testing.T) {
conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithInsecure())
if err != nil {
t.Fatal(err)
}
defer func() {
_ = conn.Close()
}()
c := nodepb.NewServiceClient(conn)
before := time.Now()
ctx := context.Background()
ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu", "age", "20")
reply, err := c.Node(ctx, &nodepb.NodeRequest{
})
if err != nil {
t.Fatal(err)
}
t.Log(reply)
t.Log(time.Since(before).Seconds()*1000, "ms")
}
func TestTLSServer(t *testing.T) {
listener, err := net.Listen("tcp", ":8001")
if err != nil {
t.Fatal(err)
}
tlsCred, err := credentials.NewServerTLSFromFile("test.pem", "test.key")
if err != nil {
t.Fatal(err)
}
s := grpc.NewServer(grpc.Creds(tlsCred))
pb.RegisterGreeterServer(s, &server{})
err = s.Serve(listener)
if err != nil {
t.Fatal(err)
}
}
func TestTLSClient(t *testing.T) {
tlsCred, err := credentials.NewClientTLSFromFile("test.pem", "www.hisock.cn")
if err != nil {
t.Fatal(err)
}
conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithTransportCredentials(tlsCred))
if err != nil {
t.Fatal(err)
}
defer func() {
_ = conn.Close()
}()
c := pb.NewGreeterClient(conn)
before := time.Now()
ctx := context.Background()
ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu")
reply, err := c.SayHello(ctx, &pb.HelloRequest{
Name: strings.Repeat("golang", 1),
})
if err != nil {
t.Fatal(err)
}
t.Log(reply.Message)
t.Log(time.Since(before).Seconds()*1000, "ms")
}
func BenchmarkClient(b *testing.B) {
runtime.GOMAXPROCS(1)
tlsCred, err := credentials.NewClientTLSFromFile("test.pem", "www.hisock.cn")
if err != nil {
b.Fatal(err)
}
conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithTransportCredentials(tlsCred))
if err != nil {
b.Fatal(err)
}
defer func() {
_ = conn.Close()
}()
c := pb.NewGreeterClient(conn)
for i := 0; i < b.N; i++ {
ctx := context.Background()
ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu")
reply, err := c.SayHello(ctx, &pb.HelloRequest{
Name: "golang",
})
_, _ = reply, err
}
}

View File

@@ -0,0 +1,45 @@
syntax = "proto3";
option go_package = "./helloworld";
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {
}
}
message HelloRequest {
string name = 100;
int32 page_number = 101;
repeated int32 ages = 102;
}
message HelloReply {
string message = 1;
}
message SearchResult {
string query = 1;
int32 page_number = 2;
int32 result_per_page = 3;
enum Corpus {
option allow_alias = true;
UNIVERSAL = 0;
WEB = 1;
IMAGES = 2;
RUNNING = 2;
}
Corpus corpus = 4;
SearchResponse result = 5;
map<string, SearchResponse> resultMap = 6;
}
message SearchResponse {
reserved 1 to 15;
int32 count = 16;
bool isOk = 17;
bytes padding = 18;
}

View File

@@ -0,0 +1,584 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: hello_service.proto
package helloworld
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type SearchResult_Corpus int32
const (
SearchResult_UNIVERSAL SearchResult_Corpus = 0
SearchResult_WEB SearchResult_Corpus = 1
SearchResult_IMAGES SearchResult_Corpus = 2
SearchResult_RUNNING SearchResult_Corpus = 2
)
// Enum value maps for SearchResult_Corpus.
var (
SearchResult_Corpus_name = map[int32]string{
0: "UNIVERSAL",
1: "WEB",
2: "IMAGES",
// Duplicate value: 2: "RUNNING",
}
SearchResult_Corpus_value = map[string]int32{
"UNIVERSAL": 0,
"WEB": 1,
"IMAGES": 2,
"RUNNING": 2,
}
)
func (x SearchResult_Corpus) Enum() *SearchResult_Corpus {
p := new(SearchResult_Corpus)
*p = x
return p
}
func (x SearchResult_Corpus) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (SearchResult_Corpus) Descriptor() protoreflect.EnumDescriptor {
return file_hello_service_proto_enumTypes[0].Descriptor()
}
func (SearchResult_Corpus) Type() protoreflect.EnumType {
return &file_hello_service_proto_enumTypes[0]
}
func (x SearchResult_Corpus) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use SearchResult_Corpus.Descriptor instead.
func (SearchResult_Corpus) EnumDescriptor() ([]byte, []int) {
return file_hello_service_proto_rawDescGZIP(), []int{2, 0}
}
type HelloRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,100,opt,name=name,proto3" json:"name,omitempty"`
PageNumber int32 `protobuf:"varint,101,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"`
Ages []int32 `protobuf:"varint,102,rep,packed,name=ages,proto3" json:"ages,omitempty"`
}
func (x *HelloRequest) Reset() {
*x = HelloRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_hello_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HelloRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HelloRequest) ProtoMessage() {}
func (x *HelloRequest) ProtoReflect() protoreflect.Message {
mi := &file_hello_service_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) Descriptor() ([]byte, []int) {
return file_hello_service_proto_rawDescGZIP(), []int{0}
}
func (x *HelloRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *HelloRequest) GetPageNumber() int32 {
if x != nil {
return x.PageNumber
}
return 0
}
func (x *HelloRequest) GetAges() []int32 {
if x != nil {
return x.Ages
}
return nil
}
type HelloReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
}
func (x *HelloReply) Reset() {
*x = HelloReply{}
if protoimpl.UnsafeEnabled {
mi := &file_hello_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HelloReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HelloReply) ProtoMessage() {}
func (x *HelloReply) ProtoReflect() protoreflect.Message {
mi := &file_hello_service_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.
func (*HelloReply) Descriptor() ([]byte, []int) {
return file_hello_service_proto_rawDescGZIP(), []int{1}
}
func (x *HelloReply) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
type SearchResult struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
PageNumber int32 `protobuf:"varint,2,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"`
ResultPerPage int32 `protobuf:"varint,3,opt,name=result_per_page,json=resultPerPage,proto3" json:"result_per_page,omitempty"`
Corpus SearchResult_Corpus `protobuf:"varint,4,opt,name=corpus,proto3,enum=SearchResult_Corpus" json:"corpus,omitempty"`
Result *SearchResponse `protobuf:"bytes,5,opt,name=result,proto3" json:"result,omitempty"`
ResultMap map[string]*SearchResponse `protobuf:"bytes,6,rep,name=resultMap,proto3" json:"resultMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *SearchResult) Reset() {
*x = SearchResult{}
if protoimpl.UnsafeEnabled {
mi := &file_hello_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SearchResult) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SearchResult) ProtoMessage() {}
func (x *SearchResult) ProtoReflect() protoreflect.Message {
mi := &file_hello_service_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SearchResult.ProtoReflect.Descriptor instead.
func (*SearchResult) Descriptor() ([]byte, []int) {
return file_hello_service_proto_rawDescGZIP(), []int{2}
}
func (x *SearchResult) GetQuery() string {
if x != nil {
return x.Query
}
return ""
}
func (x *SearchResult) GetPageNumber() int32 {
if x != nil {
return x.PageNumber
}
return 0
}
func (x *SearchResult) GetResultPerPage() int32 {
if x != nil {
return x.ResultPerPage
}
return 0
}
func (x *SearchResult) GetCorpus() SearchResult_Corpus {
if x != nil {
return x.Corpus
}
return SearchResult_UNIVERSAL
}
func (x *SearchResult) GetResult() *SearchResponse {
if x != nil {
return x.Result
}
return nil
}
func (x *SearchResult) GetResultMap() map[string]*SearchResponse {
if x != nil {
return x.ResultMap
}
return nil
}
type SearchResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Count int32 `protobuf:"varint,16,opt,name=count,proto3" json:"count,omitempty"`
IsOk bool `protobuf:"varint,17,opt,name=isOk,proto3" json:"isOk,omitempty"`
Padding []byte `protobuf:"bytes,18,opt,name=padding,proto3" json:"padding,omitempty"`
}
func (x *SearchResponse) Reset() {
*x = SearchResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_hello_service_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SearchResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SearchResponse) ProtoMessage() {}
func (x *SearchResponse) ProtoReflect() protoreflect.Message {
mi := &file_hello_service_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead.
func (*SearchResponse) Descriptor() ([]byte, []int) {
return file_hello_service_proto_rawDescGZIP(), []int{3}
}
func (x *SearchResponse) GetCount() int32 {
if x != nil {
return x.Count
}
return 0
}
func (x *SearchResponse) GetIsOk() bool {
if x != nil {
return x.IsOk
}
return false
}
func (x *SearchResponse) GetPadding() []byte {
if x != nil {
return x.Padding
}
return nil
}
var File_hello_service_proto protoreflect.FileDescriptor
var file_hello_service_proto_rawDesc = []byte{
0x0a, 0x13, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x64, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x67,
0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x65, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x67,
0x65, 0x73, 0x18, 0x66, 0x20, 0x03, 0x28, 0x05, 0x52, 0x04, 0x61, 0x67, 0x65, 0x73, 0x22, 0x26,
0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07,
0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x8e, 0x03, 0x0a, 0x0c, 0x53, 0x65, 0x61, 0x72, 0x63,
0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1f, 0x0a,
0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01,
0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26,
0x0a, 0x0f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x67,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x50,
0x65, 0x72, 0x50, 0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x63, 0x6f, 0x72, 0x70, 0x75, 0x73,
0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52,
0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x43, 0x6f, 0x72, 0x70, 0x75, 0x73, 0x52, 0x06, 0x63, 0x6f,
0x72, 0x70, 0x75, 0x73, 0x12, 0x27, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x05,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x3a, 0x0a,
0x09, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x1c, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e,
0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09,
0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x1a, 0x4d, 0x0a, 0x0e, 0x52, 0x65, 0x73,
0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53,
0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3d, 0x0a, 0x06, 0x43, 0x6f, 0x72, 0x70,
0x75, 0x73, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x49, 0x56, 0x45, 0x52, 0x53, 0x41, 0x4c, 0x10,
0x00, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x45, 0x42, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x4d,
0x41, 0x47, 0x45, 0x53, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e,
0x47, 0x10, 0x02, 0x1a, 0x02, 0x10, 0x01, 0x22, 0x5a, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63,
0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75,
0x6e, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12,
0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69,
0x73, 0x4f, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x12,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x4a, 0x04, 0x08,
0x01, 0x10, 0x10, 0x32, 0x33, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x28,
0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x0d, 0x2e, 0x48, 0x65, 0x6c,
0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x48, 0x65, 0x6c, 0x6c,
0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x68, 0x65,
0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_hello_service_proto_rawDescOnce sync.Once
file_hello_service_proto_rawDescData = file_hello_service_proto_rawDesc
)
func file_hello_service_proto_rawDescGZIP() []byte {
file_hello_service_proto_rawDescOnce.Do(func() {
file_hello_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_hello_service_proto_rawDescData)
})
return file_hello_service_proto_rawDescData
}
var file_hello_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_hello_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_hello_service_proto_goTypes = []interface{}{
(SearchResult_Corpus)(0), // 0: SearchResult.Corpus
(*HelloRequest)(nil), // 1: HelloRequest
(*HelloReply)(nil), // 2: HelloReply
(*SearchResult)(nil), // 3: SearchResult
(*SearchResponse)(nil), // 4: SearchResponse
nil, // 5: SearchResult.ResultMapEntry
}
var file_hello_service_proto_depIdxs = []int32{
0, // 0: SearchResult.corpus:type_name -> SearchResult.Corpus
4, // 1: SearchResult.result:type_name -> SearchResponse
5, // 2: SearchResult.resultMap:type_name -> SearchResult.ResultMapEntry
4, // 3: SearchResult.ResultMapEntry.value:type_name -> SearchResponse
1, // 4: Greeter.SayHello:input_type -> HelloRequest
2, // 5: Greeter.SayHello:output_type -> HelloReply
5, // [5:6] is the sub-list for method output_type
4, // [4:5] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_hello_service_proto_init() }
func file_hello_service_proto_init() {
if File_hello_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_hello_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HelloRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hello_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HelloReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hello_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SearchResult); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hello_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SearchResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_hello_service_proto_rawDesc,
NumEnums: 1,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_hello_service_proto_goTypes,
DependencyIndexes: file_hello_service_proto_depIdxs,
EnumInfos: file_hello_service_proto_enumTypes,
MessageInfos: file_hello_service_proto_msgTypes,
}.Build()
File_hello_service_proto = out.File
file_hello_service_proto_rawDesc = nil
file_hello_service_proto_goTypes = nil
file_hello_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// GreeterClient is the client API for Greeter service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type GreeterClient interface {
SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
}
type greeterClient struct {
cc grpc.ClientConnInterface
}
func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
return &greeterClient{cc}
}
func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
out := new(HelloReply)
err := c.cc.Invoke(ctx, "/Greeter/SayHello", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GreeterServer is the server API for Greeter service.
type GreeterServer interface {
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
}
// UnimplementedGreeterServer can be embedded to have forward compatible implementations.
type UnimplementedGreeterServer struct {
}
func (*UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
}
func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) {
s.RegisterService(&_Greeter_serviceDesc, srv)
}
func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HelloRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GreeterServer).SayHello(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Greeter/SayHello",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Greeter_serviceDesc = grpc.ServiceDesc{
ServiceName: "Greeter",
HandlerType: (*GreeterServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "SayHello",
Handler: _Greeter_SayHello_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "hello_service.proto",
}

27
internal/tests/test.key Normal file
View File

@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAyGF004EdKgfzTOzE52+0GRLbnrT/40AcxTG2KWd4wwdANltP
zX5NmUlH3mDJQtcLS9FzFwsIUGa3vCDCFL+b9GtM5695boykzj731amVVrv86yIL
jsYk3CtFMuEEIn7qoxfYl/P/4IJOeQN6z/yodAHYGR8QRGnjqfo6ZtPOUheo6QN/
8O2n176KsQ67lU/854oxjFZmzAgD1gnwCxVupwQkcNB7hkKW8dhEHR9oAGnEbZnJ
vPHqftwfMMDZ/0RIwIN31g17MNREC30VLEfPqIL6+a9S77yBXvTEIGSvdKetAe68
4KJFgLw9EBeAk320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