From 943742b83640dea21c8717cf56f210f3dca41ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Fri, 24 Jul 2020 09:17:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=80=A7=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/grpc.sh | 19 +- internal/apis/api_node.go | 26 +- internal/db/models/node_cluster_dao.go | 2 +- internal/db/models/node_dao.go | 47 + internal/rpc/admin/service.go | 181 -- internal/rpc/admin/service.pb.go | 881 --------- internal/rpc/admin/service.proto | 64 - internal/rpc/dns/service.go | 4 - internal/rpc/dns/service.proto | 9 - internal/rpc/log/service.go | 4 - internal/rpc/log/service.proto | 9 - internal/rpc/monitor/service.go | 4 - internal/rpc/monitor/service.pb.go | 111 -- internal/rpc/monitor/service.proto | 9 - internal/rpc/node/service.go | 16 - internal/rpc/pb/model_cluster.pb.go | 165 ++ internal/rpc/pb/model_node.pb.go | 169 ++ internal/rpc/pb/service_admin.pb.go | 1588 +++++++++++++++++ .../service.pb.go => pb/service_dns.pb.go} | 70 +- .../service.pb.go => pb/service_log.pb.go} | 70 +- internal/rpc/pb/service_monitor.pb.go | 111 ++ .../service.pb.go => pb/service_node.pb.go} | 142 +- internal/rpc/pb/service_provider.pb.go | 111 ++ .../service.pb.go => pb/service_stat.pb.go} | 68 +- .../service.pb.go => pb/service_user.pb.go} | 68 +- internal/rpc/protos/model_cluster.proto | 10 + internal/rpc/protos/model_node.proto | 13 + internal/rpc/protos/service_admin.proto | 119 ++ internal/rpc/protos/service_dns.proto | 9 + internal/rpc/protos/service_log.proto | 9 + internal/rpc/protos/service_monitor.proto | 9 + .../service_node.proto} | 6 +- internal/rpc/protos/service_provider.proto | 9 + internal/rpc/protos/service_stat.proto | 9 + internal/rpc/protos/service_user.proto | 8 + internal/rpc/provider/provider.pb.go | 112 -- internal/rpc/provider/provider.proto | 9 - internal/rpc/provider/service.go | 4 - internal/rpc/services/service_admin.go | 270 +++ .../service_admin_test.go} | 26 +- internal/rpc/services/service_dns.go | 4 + internal/rpc/services/service_log.go | 4 + internal/rpc/services/service_monitor.go | 4 + internal/rpc/services/service_node.go | 17 + internal/rpc/services/service_provider.go | 4 + internal/rpc/services/service_stat.go | 4 + internal/rpc/services/service_user.go | 4 + internal/rpc/stat/service.go | 4 - internal/rpc/stat/service.proto | 9 - internal/rpc/user/service.go | 4 - internal/rpc/user/service.proto | 9 - internal/tests/grpc_test.go | 11 +- internal/tests/helper_test.go | 10 + 53 files changed, 2962 insertions(+), 1696 deletions(-) delete mode 100644 internal/rpc/admin/service.go delete mode 100644 internal/rpc/admin/service.pb.go delete mode 100644 internal/rpc/admin/service.proto delete mode 100644 internal/rpc/dns/service.go delete mode 100644 internal/rpc/dns/service.proto delete mode 100644 internal/rpc/log/service.go delete mode 100644 internal/rpc/log/service.proto delete mode 100644 internal/rpc/monitor/service.go delete mode 100644 internal/rpc/monitor/service.pb.go delete mode 100644 internal/rpc/monitor/service.proto delete mode 100644 internal/rpc/node/service.go create mode 100644 internal/rpc/pb/model_cluster.pb.go create mode 100644 internal/rpc/pb/model_node.pb.go create mode 100644 internal/rpc/pb/service_admin.pb.go rename internal/rpc/{dns/service.pb.go => pb/service_dns.pb.go} (51%) rename internal/rpc/{log/service.pb.go => pb/service_log.pb.go} (51%) create mode 100644 internal/rpc/pb/service_monitor.pb.go rename internal/rpc/{node/service.pb.go => pb/service_node.pb.go} (54%) create mode 100644 internal/rpc/pb/service_provider.pb.go rename internal/rpc/{stat/service.pb.go => pb/service_stat.pb.go} (52%) rename internal/rpc/{user/service.pb.go => pb/service_user.pb.go} (52%) create mode 100644 internal/rpc/protos/model_cluster.proto create mode 100644 internal/rpc/protos/model_node.proto create mode 100644 internal/rpc/protos/service_admin.proto create mode 100644 internal/rpc/protos/service_dns.proto create mode 100644 internal/rpc/protos/service_log.proto create mode 100644 internal/rpc/protos/service_monitor.proto rename internal/rpc/{node/service.proto => protos/service_node.proto} (73%) create mode 100644 internal/rpc/protos/service_provider.proto create mode 100644 internal/rpc/protos/service_stat.proto create mode 100644 internal/rpc/protos/service_user.proto delete mode 100644 internal/rpc/provider/provider.pb.go delete mode 100644 internal/rpc/provider/provider.proto delete mode 100644 internal/rpc/provider/service.go create mode 100644 internal/rpc/services/service_admin.go rename internal/rpc/{admin/service_test.go => services/service_admin_test.go} (67%) create mode 100644 internal/rpc/services/service_dns.go create mode 100644 internal/rpc/services/service_log.go create mode 100644 internal/rpc/services/service_monitor.go create mode 100644 internal/rpc/services/service_node.go create mode 100644 internal/rpc/services/service_provider.go create mode 100644 internal/rpc/services/service_stat.go create mode 100644 internal/rpc/services/service_user.go delete mode 100644 internal/rpc/stat/service.go delete mode 100644 internal/rpc/stat/service.proto delete mode 100644 internal/rpc/user/service.go delete mode 100644 internal/rpc/user/service.proto diff --git a/build/grpc.sh b/build/grpc.sh index a04830e7..e61f0ea6 100755 --- a/build/grpc.sh +++ b/build/grpc.sh @@ -1,14 +1,11 @@ #!/usr/bin/env bash -function proto_compile() { - protoc --go_out=plugins=grpc:../internal/rpc --proto_path=../internal/rpc ../internal/rpc/${1}/*.proto -} +ADMIN_PROJECT="../../EdgeAdmin" + +protoc --go_out=plugins=grpc:../internal/rpc --proto_path=../internal/rpc/protos ../internal/rpc/protos/*.proto + +#admin +cp ../internal/rpc/protos/service_admin.proto ${ADMIN_PROJECT}/internal/rpc/protos/ +cp ../internal/rpc/pb/service_admin.pb.go ${ADMIN_PROJECT}/internal/rpc/pb/ +cp ../internal/rpc/pb/model_*.go ${ADMIN_PROJECT}/internal/rpc/pb/ -proto_compile "admin" -proto_compile "dns" -proto_compile "log" -proto_compile "provider" -proto_compile "stat" -proto_compile "user" -proto_compile "monitor" -proto_compile "node" \ No newline at end of file diff --git a/internal/apis/api_node.go b/internal/apis/api_node.go index 3f9b29b0..8594ebe0 100644 --- a/internal/apis/api_node.go +++ b/internal/apis/api_node.go @@ -3,14 +3,8 @@ package apis import ( "errors" "github.com/TeaOSLab/EdgeAPI/internal/configs" - "github.com/TeaOSLab/EdgeAPI/internal/rpc/admin" - "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/TeaOSLab/EdgeAPI/internal/rpc/pb" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/logs" "google.golang.org/grpc" @@ -57,14 +51,14 @@ func (this *APINode) listenRPC() error { 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{}) - admin.RegisterServiceServer(rpcServer, &admin.Service{}) + pb.RegisterDnsServiceServer(rpcServer, &services.DNSService{}) + pb.RegisterLogServiceServer(rpcServer, &services.LogService{}) + pb.RegisterMonitorServiceServer(rpcServer, &services.MonitorService{}) + pb.RegisterNodeServiceServer(rpcServer, &services.NodeService{}) + pb.RegisterProviderServiceServer(rpcServer, &services.ProviderService{}) + pb.RegisterStatServiceServer(rpcServer, &services.StatService{}) + pb.RegisterUserServiceServer(rpcServer, &services.UserService{}) + pb.RegisterAdminServiceServer(rpcServer, &services.AdminService{}) err = rpcServer.Serve(listener) if err != nil { return errors.New("[API]start rpc failed: " + err.Error()) diff --git a/internal/db/models/node_cluster_dao.go b/internal/db/models/node_cluster_dao.go index b665b51b..38e6f6ea 100644 --- a/internal/db/models/node_cluster_dao.go +++ b/internal/db/models/node_cluster_dao.go @@ -55,7 +55,7 @@ func (this *NodeClusterDAO) FindEnabledNodeCluster(id uint32) (*NodeCluster, err } // 根据主键查找名称 -func (this *NodeClusterDAO) FindNodeClusterName(id uint32) (string, error) { +func (this *NodeClusterDAO) FindNodeClusterName(id int64) (string, error) { return this.Query(). Pk(id). Result("name"). diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index 3f6468da..b48887bc 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -4,6 +4,8 @@ import ( _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) const ( @@ -62,3 +64,48 @@ func (this *NodeDAO) FindNodeName(id uint32) (string, error) { FindCol("") return name.(string), err } + +// 创建节点 +func (this *NodeDAO) CreateNode(name string, clusterId int) (nodeId int, err error) { + op := NewNodeOperator() + op.Name = name + op.NodeId = rands.HexString(32) + op.Secret = rands.String(32) + op.ClusterId = clusterId + op.State = NodeStateEnabled + _, err = this.Save(op) + if err != nil { + return 0, err + } + + return types.Int(op.Id), nil +} + +// 修改节点 +func (this *NodeDAO) UpdateNode(nodeId int, name string, clusterId int) error { + op := NewNodeOperator() + op.Id = nodeId + op.Name = name + op.ClusterId = clusterId + _, err := this.Save(op) + return err +} + +// 计算所有节点数量 +func (this *NodeDAO) CountAllEnabledNodes() (int64, error) { + return this.Query(). + State(NodeStateEnabled). + Count() +} + +// 列出单页节点 +func (this *NodeDAO) ListEnabledNodes(offset int64, size int64) (result []*Node, err error) { + _, err = this.Query(). + State(NodeStateEnabled). + Offset(int(offset)). + Limit(int(size)). + DescPk(). + Slice(&result). + FindAll() + return +} diff --git a/internal/rpc/admin/service.go b/internal/rpc/admin/service.go deleted file mode 100644 index f05ee4c8..00000000 --- a/internal/rpc/admin/service.go +++ /dev/null @@ -1,181 +0,0 @@ -package admin - -import ( - "context" - "encoding/base64" - "encoding/json" - "errors" - teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" - "github.com/TeaOSLab/EdgeAPI/internal/db/models" - "github.com/TeaOSLab/EdgeAPI/internal/encrypt" - "github.com/TeaOSLab/EdgeAPI/internal/utils" - "github.com/iwind/TeaGo/maps" - "google.golang.org/grpc/metadata" - "time" -) - -type Service struct { - debug bool -} - -func (this *Service) Login(ctx context.Context, req *LoginRequest) (*LoginResponse, error) { - _, err := this.validateRequest(ctx) - if err != nil { - return nil, err - } - - if len(req.Username) == 0 || len(req.Password) == 0 { - return &LoginResponse{ - AdminId: 0, - IsOk: false, - Message: "请输入正确的用户名密码", - }, nil - } - - adminId, err := models.SharedAdminDAO.CheckAdminPassword(req.Username, req.Password) - if err != nil { - utils.PrintError(err) - return nil, err - } - - if adminId <= 0 { - return &LoginResponse{ - AdminId: 0, - IsOk: false, - Message: "请输入正确的用户名密码", - }, nil - } - - return &LoginResponse{ - AdminId: int64(adminId), - IsOk: true, - }, nil -} - -func (this *Service) CreateLog(ctx context.Context, req *CreateLogRequest) (*CreateLogResponse, error) { - adminId, err := this.validateAdminRequest(ctx) - if err != nil { - return nil, err - } - err = models.SharedLogDAO.CreateAdminLog(adminId, req.Level, req.Description, req.Action, req.Ip) - return &CreateLogResponse{ - IsOk: err != nil, - }, err -} - -func (this *Service) CheckAdminExists(ctx context.Context, req *CheckAdminExistsRequest) (*CheckAdminExistsResponse, error) { - _, err := this.validateRequest(ctx) - if err != nil { - return nil, err - } - - if req.AdminId <= 0 { - return &CheckAdminExistsResponse{ - IsOk: false, - }, nil - } - - ok, err := models.SharedAdminDAO.ExistEnabledAdmin(int(req.AdminId)) - if err != nil { - return nil, err - } - - return &CheckAdminExistsResponse{ - IsOk: ok, - }, nil -} - -func (this *Service) FindAdminFullname(ctx context.Context, req *FindAdminNameRequest) (*FindAdminNameResponse, error) { - _, err := this.validateRequest(ctx) - if err != nil { - return nil, err - } - - fullname, err := models.SharedAdminDAO.FindAdminFullname(int(req.AdminId)) - if err != nil { - utils.PrintError(err) - return nil, err - } - - return &FindAdminNameResponse{ - Fullname: fullname, - }, nil -} - -func (this *Service) validateRequest(ctx context.Context) (adminId int, err error) { - var md metadata.MD - var ok bool - if this.debug { - md, ok = metadata.FromOutgoingContext(ctx) - } else { - md, ok = metadata.FromIncomingContext(ctx) - } - if !ok { - return 0, errors.New("context: need 'nodeId'") - } - nodeIds := md.Get("nodeid") - if len(nodeIds) == 0 || len(nodeIds[0]) == 0 { - return 0, errors.New("context: need 'nodeId'") - } - nodeId := nodeIds[0] - - // 获取Node信息 - apiToken, err := models.SharedApiTokenDAO.FindEnabledTokenWithNode(nodeId) - if err != nil { - utils.PrintError(err) - return 0, err - } - if apiToken == nil { - return 0, errors.New("can not find token from node id: " + err.Error()) - } - - tokens := md.Get("token") - if len(tokens) == 0 || len(tokens[0]) == 0 { - return 0, errors.New("context: need 'token'") - } - token := tokens[0] - - data, err := base64.StdEncoding.DecodeString(token) - if err != nil { - return 0, err - } - - method, err := encrypt.NewMethodInstance(teaconst.EncryptMethod, apiToken.Secret, nodeId) - if err != nil { - utils.PrintError(err) - return 0, err - } - data, err = method.Decrypt(data) - if err != nil { - return 0, err - } - if len(data) == 0 { - return 0, errors.New("invalid token") - } - - m := maps.Map{} - err = json.Unmarshal(data, &m) - if err != nil { - return 0, errors.New("decode token error: " + err.Error()) - } - - timestamp := m.GetInt64("timestamp") - if time.Now().Unix()-timestamp > 600 { - // 请求超过10分钟认为超时 - return 0, errors.New("authenticate timeout") - } - - adminId = m.GetInt("adminId") - return -} - -func (this *Service) validateAdminRequest(ctx context.Context) (adminId int, err error) { - adminId, err = this.validateRequest(ctx) - if err != nil { - return 0, err - } - if adminId <= 0 { - return 0, errors.New("invalid admin id") - } - return -} diff --git a/internal/rpc/admin/service.pb.go b/internal/rpc/admin/service.pb.go deleted file mode 100644 index 60aa673e..00000000 --- a/internal/rpc/admin/service.pb.go +++ /dev/null @@ -1,881 +0,0 @@ -// 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 - - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` -} - -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} -} - -func (x *LoginRequest) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *LoginRequest) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type LoginResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - AdminId int64 `protobuf:"varint,1,opt,name=adminId,proto3" json:"adminId,omitempty"` - IsOk bool `protobuf:"varint,2,opt,name=isOk,proto3" json:"isOk,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` -} - -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} -} - -func (x *LoginResponse) GetAdminId() int64 { - if x != nil { - return x.AdminId - } - return 0 -} - -func (x *LoginResponse) GetIsOk() bool { - if x != nil { - return x.IsOk - } - return false -} - -func (x *LoginResponse) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -type CreateLogRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Level string `protobuf:"bytes,1,opt,name=level,proto3" json:"level,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Action string `protobuf:"bytes,3,opt,name=action,proto3" json:"action,omitempty"` - Ip string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip,omitempty"` -} - -func (x *CreateLogRequest) Reset() { - *x = CreateLogRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_admin_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateLogRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateLogRequest) ProtoMessage() {} - -func (x *CreateLogRequest) ProtoReflect() protoreflect.Message { - mi := &file_admin_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 CreateLogRequest.ProtoReflect.Descriptor instead. -func (*CreateLogRequest) Descriptor() ([]byte, []int) { - return file_admin_service_proto_rawDescGZIP(), []int{2} -} - -func (x *CreateLogRequest) GetLevel() string { - if x != nil { - return x.Level - } - return "" -} - -func (x *CreateLogRequest) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *CreateLogRequest) GetAction() string { - if x != nil { - return x.Action - } - return "" -} - -func (x *CreateLogRequest) GetIp() string { - if x != nil { - return x.Ip - } - return "" -} - -type CreateLogResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - IsOk bool `protobuf:"varint,1,opt,name=isOk,proto3" json:"isOk,omitempty"` -} - -func (x *CreateLogResponse) Reset() { - *x = CreateLogResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_admin_service_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateLogResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateLogResponse) ProtoMessage() {} - -func (x *CreateLogResponse) ProtoReflect() protoreflect.Message { - mi := &file_admin_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 CreateLogResponse.ProtoReflect.Descriptor instead. -func (*CreateLogResponse) Descriptor() ([]byte, []int) { - return file_admin_service_proto_rawDescGZIP(), []int{3} -} - -func (x *CreateLogResponse) GetIsOk() bool { - if x != nil { - return x.IsOk - } - return false -} - -type CheckAdminExistsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - AdminId int64 `protobuf:"varint,1,opt,name=adminId,proto3" json:"adminId,omitempty"` -} - -func (x *CheckAdminExistsRequest) Reset() { - *x = CheckAdminExistsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_admin_service_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CheckAdminExistsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CheckAdminExistsRequest) ProtoMessage() {} - -func (x *CheckAdminExistsRequest) ProtoReflect() protoreflect.Message { - mi := &file_admin_service_proto_msgTypes[4] - 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 CheckAdminExistsRequest.ProtoReflect.Descriptor instead. -func (*CheckAdminExistsRequest) Descriptor() ([]byte, []int) { - return file_admin_service_proto_rawDescGZIP(), []int{4} -} - -func (x *CheckAdminExistsRequest) GetAdminId() int64 { - if x != nil { - return x.AdminId - } - return 0 -} - -type CheckAdminExistsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - IsOk bool `protobuf:"varint,1,opt,name=isOk,proto3" json:"isOk,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *CheckAdminExistsResponse) Reset() { - *x = CheckAdminExistsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_admin_service_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CheckAdminExistsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CheckAdminExistsResponse) ProtoMessage() {} - -func (x *CheckAdminExistsResponse) ProtoReflect() protoreflect.Message { - mi := &file_admin_service_proto_msgTypes[5] - 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 CheckAdminExistsResponse.ProtoReflect.Descriptor instead. -func (*CheckAdminExistsResponse) Descriptor() ([]byte, []int) { - return file_admin_service_proto_rawDescGZIP(), []int{5} -} - -func (x *CheckAdminExistsResponse) GetIsOk() bool { - if x != nil { - return x.IsOk - } - return false -} - -func (x *CheckAdminExistsResponse) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -type FindAdminNameRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - AdminId int64 `protobuf:"varint,1,opt,name=adminId,proto3" json:"adminId,omitempty"` -} - -func (x *FindAdminNameRequest) Reset() { - *x = FindAdminNameRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_admin_service_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FindAdminNameRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FindAdminNameRequest) ProtoMessage() {} - -func (x *FindAdminNameRequest) ProtoReflect() protoreflect.Message { - mi := &file_admin_service_proto_msgTypes[6] - 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 FindAdminNameRequest.ProtoReflect.Descriptor instead. -func (*FindAdminNameRequest) Descriptor() ([]byte, []int) { - return file_admin_service_proto_rawDescGZIP(), []int{6} -} - -func (x *FindAdminNameRequest) GetAdminId() int64 { - if x != nil { - return x.AdminId - } - return 0 -} - -type FindAdminNameResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Fullname string `protobuf:"bytes,1,opt,name=fullname,proto3" json:"fullname,omitempty"` -} - -func (x *FindAdminNameResponse) Reset() { - *x = FindAdminNameResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_admin_service_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FindAdminNameResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FindAdminNameResponse) ProtoMessage() {} - -func (x *FindAdminNameResponse) ProtoReflect() protoreflect.Message { - mi := &file_admin_service_proto_msgTypes[7] - 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 FindAdminNameResponse.ProtoReflect.Descriptor instead. -func (*FindAdminNameResponse) Descriptor() ([]byte, []int) { - return file_admin_service_proto_rawDescGZIP(), []int{7} -} - -func (x *FindAdminNameResponse) GetFullname() string { - if x != nil { - return x.Fullname - } - return "" -} - -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, 0x46, 0x0a, 0x0c, - 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, - 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, - 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, - 0x77, 0x6f, 0x72, 0x64, 0x22, 0x57, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x12, - 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, - 0x73, 0x4f, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x72, 0x0a, - 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x70, 0x22, 0x27, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x22, 0x33, 0x0a, 0x17, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x22, - 0x48, 0x0a, 0x18, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, - 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, - 0x73, 0x4f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x30, 0x0a, 0x14, 0x46, 0x69, 0x6e, - 0x64, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x22, 0x33, 0x0a, 0x15, 0x46, - 0x69, 0x6e, 0x64, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65, - 0x32, 0xaa, 0x02, 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, 0x12, 0x40, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x12, - 0x17, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x6f, - 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x10, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, - 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x12, 0x1e, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, 0x74, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x11, 0x66, - 0x69, 0x6e, 0x64, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x1b, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x6d, - 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, - 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4e, - 0x61, 0x6d, 0x65, 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, 8) -var file_admin_service_proto_goTypes = []interface{}{ - (*LoginRequest)(nil), // 0: admin.LoginRequest - (*LoginResponse)(nil), // 1: admin.LoginResponse - (*CreateLogRequest)(nil), // 2: admin.CreateLogRequest - (*CreateLogResponse)(nil), // 3: admin.CreateLogResponse - (*CheckAdminExistsRequest)(nil), // 4: admin.CheckAdminExistsRequest - (*CheckAdminExistsResponse)(nil), // 5: admin.CheckAdminExistsResponse - (*FindAdminNameRequest)(nil), // 6: admin.FindAdminNameRequest - (*FindAdminNameResponse)(nil), // 7: admin.FindAdminNameResponse -} -var file_admin_service_proto_depIdxs = []int32{ - 0, // 0: admin.Service.login:input_type -> admin.LoginRequest - 2, // 1: admin.Service.createLog:input_type -> admin.CreateLogRequest - 4, // 2: admin.Service.checkAdminExists:input_type -> admin.CheckAdminExistsRequest - 6, // 3: admin.Service.findAdminFullname:input_type -> admin.FindAdminNameRequest - 1, // 4: admin.Service.login:output_type -> admin.LoginResponse - 3, // 5: admin.Service.createLog:output_type -> admin.CreateLogResponse - 5, // 6: admin.Service.checkAdminExists:output_type -> admin.CheckAdminExistsResponse - 7, // 7: admin.Service.findAdminFullname:output_type -> admin.FindAdminNameResponse - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] 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 - } - } - file_admin_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateLogRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_admin_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateLogResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_admin_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckAdminExistsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_admin_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckAdminExistsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_admin_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FindAdminNameRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_admin_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FindAdminNameResponse); 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: 8, - 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) - // 创建操作日志 - CreateLog(ctx context.Context, in *CreateLogRequest, opts ...grpc.CallOption) (*CreateLogResponse, error) - // 检查管理员是否存在 - CheckAdminExists(ctx context.Context, in *CheckAdminExistsRequest, opts ...grpc.CallOption) (*CheckAdminExistsResponse, error) - // 获取管理员名称 - FindAdminFullname(ctx context.Context, in *FindAdminNameRequest, opts ...grpc.CallOption) (*FindAdminNameResponse, 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 -} - -func (c *serviceClient) CreateLog(ctx context.Context, in *CreateLogRequest, opts ...grpc.CallOption) (*CreateLogResponse, error) { - out := new(CreateLogResponse) - err := c.cc.Invoke(ctx, "/admin.Service/createLog", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) CheckAdminExists(ctx context.Context, in *CheckAdminExistsRequest, opts ...grpc.CallOption) (*CheckAdminExistsResponse, error) { - out := new(CheckAdminExistsResponse) - err := c.cc.Invoke(ctx, "/admin.Service/checkAdminExists", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) FindAdminFullname(ctx context.Context, in *FindAdminNameRequest, opts ...grpc.CallOption) (*FindAdminNameResponse, error) { - out := new(FindAdminNameResponse) - err := c.cc.Invoke(ctx, "/admin.Service/findAdminFullname", 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) - // 创建操作日志 - CreateLog(context.Context, *CreateLogRequest) (*CreateLogResponse, error) - // 检查管理员是否存在 - CheckAdminExists(context.Context, *CheckAdminExistsRequest) (*CheckAdminExistsResponse, error) - // 获取管理员名称 - FindAdminFullname(context.Context, *FindAdminNameRequest) (*FindAdminNameResponse, 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 (*UnimplementedServiceServer) CreateLog(context.Context, *CreateLogRequest) (*CreateLogResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateLog not implemented") -} -func (*UnimplementedServiceServer) CheckAdminExists(context.Context, *CheckAdminExistsRequest) (*CheckAdminExistsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CheckAdminExists not implemented") -} -func (*UnimplementedServiceServer) FindAdminFullname(context.Context, *FindAdminNameRequest) (*FindAdminNameResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FindAdminFullname 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) -} - -func _Service_CreateLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateLogRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).CreateLog(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/admin.Service/CreateLog", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).CreateLog(ctx, req.(*CreateLogRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_CheckAdminExists_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CheckAdminExistsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).CheckAdminExists(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/admin.Service/CheckAdminExists", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).CheckAdminExists(ctx, req.(*CheckAdminExistsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_FindAdminFullname_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(FindAdminNameRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).FindAdminFullname(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/admin.Service/FindAdminFullname", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).FindAdminFullname(ctx, req.(*FindAdminNameRequest)) - } - 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, - }, - { - MethodName: "createLog", - Handler: _Service_CreateLog_Handler, - }, - { - MethodName: "checkAdminExists", - Handler: _Service_CheckAdminExists_Handler, - }, - { - MethodName: "findAdminFullname", - Handler: _Service_FindAdminFullname_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "admin/service.proto", -} diff --git a/internal/rpc/admin/service.proto b/internal/rpc/admin/service.proto deleted file mode 100644 index 80ead3dd..00000000 --- a/internal/rpc/admin/service.proto +++ /dev/null @@ -1,64 +0,0 @@ -syntax = "proto3"; -option go_package = "./admin"; - -package admin; - -service Service { - // 登录 - rpc login (LoginRequest) returns (LoginResponse) { - } - - // 创建操作日志 - rpc createLog (CreateLogRequest) returns (CreateLogResponse) { - } - - // 检查管理员是否存在 - rpc checkAdminExists (CheckAdminExistsRequest) returns (CheckAdminExistsResponse) { - - } - - // 获取管理员名称 - rpc findAdminFullname (FindAdminNameRequest) returns (FindAdminNameResponse) { - - } -} - -message LoginRequest { - string username = 1; - string password = 2; -} - -message LoginResponse { - int64 adminId = 1; - bool isOk = 2; - string message = 3; -} - -message CreateLogRequest { - string level = 1; - string description = 2; - string action = 3; - string ip = 4; -} - -message CreateLogResponse { - bool isOk = 1; -} - -message CheckAdminExistsRequest { - int64 adminId = 1; -} - -message CheckAdminExistsResponse { - bool isOk = 1; - string message = 2; -} - - -message FindAdminNameRequest { - int64 adminId = 1; -} - -message FindAdminNameResponse { - string fullname = 1; -} diff --git a/internal/rpc/dns/service.go b/internal/rpc/dns/service.go deleted file mode 100644 index d6b4fce8..00000000 --- a/internal/rpc/dns/service.go +++ /dev/null @@ -1,4 +0,0 @@ -package dns - -type Service struct { -} diff --git a/internal/rpc/dns/service.proto b/internal/rpc/dns/service.proto deleted file mode 100644 index 41dc48a8..00000000 --- a/internal/rpc/dns/service.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package dns; - -option go_package = "./dns"; - -service Service { - -} diff --git a/internal/rpc/log/service.go b/internal/rpc/log/service.go deleted file mode 100644 index 877884f1..00000000 --- a/internal/rpc/log/service.go +++ /dev/null @@ -1,4 +0,0 @@ -package log - -type Service struct { -} diff --git a/internal/rpc/log/service.proto b/internal/rpc/log/service.proto deleted file mode 100644 index 5822a8ca..00000000 --- a/internal/rpc/log/service.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package log; - -option go_package = "./log"; - -service Service { - -} diff --git a/internal/rpc/monitor/service.go b/internal/rpc/monitor/service.go deleted file mode 100644 index dd0066c5..00000000 --- a/internal/rpc/monitor/service.go +++ /dev/null @@ -1,4 +0,0 @@ -package monitor - -type Service struct { -} diff --git a/internal/rpc/monitor/service.pb.go b/internal/rpc/monitor/service.pb.go deleted file mode 100644 index 5a9a0667..00000000 --- a/internal/rpc/monitor/service.pb.go +++ /dev/null @@ -1,111 +0,0 @@ -// 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", -} diff --git a/internal/rpc/monitor/service.proto b/internal/rpc/monitor/service.proto deleted file mode 100644 index 84a13e5c..00000000 --- a/internal/rpc/monitor/service.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package monitor; - -option go_package = "./monitor"; - -service Service { - -} diff --git a/internal/rpc/node/service.go b/internal/rpc/node/service.go deleted file mode 100644 index dfa6af99..00000000 --- a/internal/rpc/node/service.go +++ /dev/null @@ -1,16 +0,0 @@ -package node - -import ( - "context" - "github.com/iwind/TeaGo/logs" -) - -type Service struct { -} - -func (this *Service) Config(ctx context.Context, req *ConfigRequest) (*ConfigResponse, error) { - logs.Println("you called me") - return &ConfigResponse{ - Id: req.NodeId, - }, nil -} diff --git a/internal/rpc/pb/model_cluster.pb.go b/internal/rpc/pb/model_cluster.pb.go new file mode 100644 index 00000000..4e731ecd --- /dev/null +++ b/internal/rpc/pb/model_cluster.pb.go @@ -0,0 +1,165 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: model_cluster.proto + +package pb + +import ( + proto "github.com/golang/protobuf/proto" + 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 Cluster struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + CreatedAt int64 `protobuf:"varint,3,opt,name=createdAt,proto3" json:"createdAt,omitempty"` +} + +func (x *Cluster) Reset() { + *x = Cluster{} + if protoimpl.UnsafeEnabled { + mi := &file_model_cluster_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Cluster) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Cluster) ProtoMessage() {} + +func (x *Cluster) ProtoReflect() protoreflect.Message { + mi := &file_model_cluster_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 Cluster.ProtoReflect.Descriptor instead. +func (*Cluster) Descriptor() ([]byte, []int) { + return file_model_cluster_proto_rawDescGZIP(), []int{0} +} + +func (x *Cluster) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Cluster) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Cluster) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + +var File_model_cluster_proto protoreflect.FileDescriptor + +var file_model_cluster_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x4b, 0x0a, 0x07, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_model_cluster_proto_rawDescOnce sync.Once + file_model_cluster_proto_rawDescData = file_model_cluster_proto_rawDesc +) + +func file_model_cluster_proto_rawDescGZIP() []byte { + file_model_cluster_proto_rawDescOnce.Do(func() { + file_model_cluster_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_cluster_proto_rawDescData) + }) + return file_model_cluster_proto_rawDescData +} + +var file_model_cluster_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_model_cluster_proto_goTypes = []interface{}{ + (*Cluster)(nil), // 0: pb.Cluster +} +var file_model_cluster_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_model_cluster_proto_init() } +func file_model_cluster_proto_init() { + if File_model_cluster_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_model_cluster_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Cluster); 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_model_cluster_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_model_cluster_proto_goTypes, + DependencyIndexes: file_model_cluster_proto_depIdxs, + MessageInfos: file_model_cluster_proto_msgTypes, + }.Build() + File_model_cluster_proto = out.File + file_model_cluster_proto_rawDesc = nil + file_model_cluster_proto_goTypes = nil + file_model_cluster_proto_depIdxs = nil +} diff --git a/internal/rpc/pb/model_node.pb.go b/internal/rpc/pb/model_node.pb.go new file mode 100644 index 00000000..e20b5730 --- /dev/null +++ b/internal/rpc/pb/model_node.pb.go @@ -0,0 +1,169 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: model_node.proto + +package pb + +import ( + proto "github.com/golang/protobuf/proto" + 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 Node struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Cluster *Cluster `protobuf:"bytes,32,opt,name=cluster,proto3" json:"cluster,omitempty"` +} + +func (x *Node) Reset() { + *x = Node{} + if protoimpl.UnsafeEnabled { + mi := &file_model_node_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Node) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Node) ProtoMessage() {} + +func (x *Node) ProtoReflect() protoreflect.Message { + mi := &file_model_node_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 Node.ProtoReflect.Descriptor instead. +func (*Node) Descriptor() ([]byte, []int) { + return file_model_node_proto_rawDescGZIP(), []int{0} +} + +func (x *Node) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Node) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Node) GetCluster() *Cluster { + if x != nil { + return x.Cluster + } + return nil +} + +var File_model_node_proto protoreflect.FileDescriptor + +var file_model_node_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x13, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x63, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x04, 0x4e, + 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x42, 0x06, + 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_model_node_proto_rawDescOnce sync.Once + file_model_node_proto_rawDescData = file_model_node_proto_rawDesc +) + +func file_model_node_proto_rawDescGZIP() []byte { + file_model_node_proto_rawDescOnce.Do(func() { + file_model_node_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_node_proto_rawDescData) + }) + return file_model_node_proto_rawDescData +} + +var file_model_node_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_model_node_proto_goTypes = []interface{}{ + (*Node)(nil), // 0: pb.Node + (*Cluster)(nil), // 1: pb.Cluster +} +var file_model_node_proto_depIdxs = []int32{ + 1, // 0: pb.Node.cluster:type_name -> pb.Cluster + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_model_node_proto_init() } +func file_model_node_proto_init() { + if File_model_node_proto != nil { + return + } + file_model_cluster_proto_init() + if !protoimpl.UnsafeEnabled { + file_model_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Node); 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_model_node_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_model_node_proto_goTypes, + DependencyIndexes: file_model_node_proto_depIdxs, + MessageInfos: file_model_node_proto_msgTypes, + }.Build() + File_model_node_proto = out.File + file_model_node_proto_rawDesc = nil + file_model_node_proto_goTypes = nil + file_model_node_proto_depIdxs = nil +} diff --git a/internal/rpc/pb/service_admin.pb.go b/internal/rpc/pb/service_admin.pb.go new file mode 100644 index 00000000..56ed4804 --- /dev/null +++ b/internal/rpc/pb/service_admin.pb.go @@ -0,0 +1,1588 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: service_admin.proto + +package pb + +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 AdminLoginRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *AdminLoginRequest) Reset() { + *x = AdminLoginRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminLoginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminLoginRequest) ProtoMessage() {} + +func (x *AdminLoginRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_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 AdminLoginRequest.ProtoReflect.Descriptor instead. +func (*AdminLoginRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{0} +} + +func (x *AdminLoginRequest) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *AdminLoginRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type AdminLoginResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdminId int64 `protobuf:"varint,1,opt,name=adminId,proto3" json:"adminId,omitempty"` + IsOk bool `protobuf:"varint,2,opt,name=isOk,proto3" json:"isOk,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *AdminLoginResponse) Reset() { + *x = AdminLoginResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminLoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminLoginResponse) ProtoMessage() {} + +func (x *AdminLoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_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 AdminLoginResponse.ProtoReflect.Descriptor instead. +func (*AdminLoginResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{1} +} + +func (x *AdminLoginResponse) GetAdminId() int64 { + if x != nil { + return x.AdminId + } + return 0 +} + +func (x *AdminLoginResponse) GetIsOk() bool { + if x != nil { + return x.IsOk + } + return false +} + +func (x *AdminLoginResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type AdminCreateLogRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Level string `protobuf:"bytes,1,opt,name=level,proto3" json:"level,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Action string `protobuf:"bytes,3,opt,name=action,proto3" json:"action,omitempty"` + Ip string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip,omitempty"` +} + +func (x *AdminCreateLogRequest) Reset() { + *x = AdminCreateLogRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCreateLogRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCreateLogRequest) ProtoMessage() {} + +func (x *AdminCreateLogRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_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 AdminCreateLogRequest.ProtoReflect.Descriptor instead. +func (*AdminCreateLogRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{2} +} + +func (x *AdminCreateLogRequest) GetLevel() string { + if x != nil { + return x.Level + } + return "" +} + +func (x *AdminCreateLogRequest) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *AdminCreateLogRequest) GetAction() string { + if x != nil { + return x.Action + } + return "" +} + +func (x *AdminCreateLogRequest) GetIp() string { + if x != nil { + return x.Ip + } + return "" +} + +type AdminCreateLogResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IsOk bool `protobuf:"varint,1,opt,name=isOk,proto3" json:"isOk,omitempty"` +} + +func (x *AdminCreateLogResponse) Reset() { + *x = AdminCreateLogResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCreateLogResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCreateLogResponse) ProtoMessage() {} + +func (x *AdminCreateLogResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_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 AdminCreateLogResponse.ProtoReflect.Descriptor instead. +func (*AdminCreateLogResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{3} +} + +func (x *AdminCreateLogResponse) GetIsOk() bool { + if x != nil { + return x.IsOk + } + return false +} + +type AdminCheckAdminExistsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdminId int64 `protobuf:"varint,1,opt,name=adminId,proto3" json:"adminId,omitempty"` +} + +func (x *AdminCheckAdminExistsRequest) Reset() { + *x = AdminCheckAdminExistsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCheckAdminExistsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCheckAdminExistsRequest) ProtoMessage() {} + +func (x *AdminCheckAdminExistsRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[4] + 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 AdminCheckAdminExistsRequest.ProtoReflect.Descriptor instead. +func (*AdminCheckAdminExistsRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{4} +} + +func (x *AdminCheckAdminExistsRequest) GetAdminId() int64 { + if x != nil { + return x.AdminId + } + return 0 +} + +type AdminCheckAdminExistsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IsOk bool `protobuf:"varint,1,opt,name=isOk,proto3" json:"isOk,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *AdminCheckAdminExistsResponse) Reset() { + *x = AdminCheckAdminExistsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCheckAdminExistsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCheckAdminExistsResponse) ProtoMessage() {} + +func (x *AdminCheckAdminExistsResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[5] + 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 AdminCheckAdminExistsResponse.ProtoReflect.Descriptor instead. +func (*AdminCheckAdminExistsResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{5} +} + +func (x *AdminCheckAdminExistsResponse) GetIsOk() bool { + if x != nil { + return x.IsOk + } + return false +} + +func (x *AdminCheckAdminExistsResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type AdminFindAdminNameRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AdminId int64 `protobuf:"varint,1,opt,name=adminId,proto3" json:"adminId,omitempty"` +} + +func (x *AdminFindAdminNameRequest) Reset() { + *x = AdminFindAdminNameRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminFindAdminNameRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminFindAdminNameRequest) ProtoMessage() {} + +func (x *AdminFindAdminNameRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[6] + 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 AdminFindAdminNameRequest.ProtoReflect.Descriptor instead. +func (*AdminFindAdminNameRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{6} +} + +func (x *AdminFindAdminNameRequest) GetAdminId() int64 { + if x != nil { + return x.AdminId + } + return 0 +} + +type AdminFindAdminNameResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Fullname string `protobuf:"bytes,1,opt,name=fullname,proto3" json:"fullname,omitempty"` +} + +func (x *AdminFindAdminNameResponse) Reset() { + *x = AdminFindAdminNameResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminFindAdminNameResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminFindAdminNameResponse) ProtoMessage() {} + +func (x *AdminFindAdminNameResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[7] + 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 AdminFindAdminNameResponse.ProtoReflect.Descriptor instead. +func (*AdminFindAdminNameResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{7} +} + +func (x *AdminFindAdminNameResponse) GetFullname() string { + if x != nil { + return x.Fullname + } + return "" +} + +type AdminFindAllEnabledClustersRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *AdminFindAllEnabledClustersRequest) Reset() { + *x = AdminFindAllEnabledClustersRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminFindAllEnabledClustersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminFindAllEnabledClustersRequest) ProtoMessage() {} + +func (x *AdminFindAllEnabledClustersRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[8] + 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 AdminFindAllEnabledClustersRequest.ProtoReflect.Descriptor instead. +func (*AdminFindAllEnabledClustersRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{8} +} + +type AdminFindAllEnabledClustersResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Clusters []*Cluster `protobuf:"bytes,1,rep,name=clusters,proto3" json:"clusters,omitempty"` +} + +func (x *AdminFindAllEnabledClustersResponse) Reset() { + *x = AdminFindAllEnabledClustersResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminFindAllEnabledClustersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminFindAllEnabledClustersResponse) ProtoMessage() {} + +func (x *AdminFindAllEnabledClustersResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[9] + 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 AdminFindAllEnabledClustersResponse.ProtoReflect.Descriptor instead. +func (*AdminFindAllEnabledClustersResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{9} +} + +func (x *AdminFindAllEnabledClustersResponse) GetClusters() []*Cluster { + if x != nil { + return x.Clusters + } + return nil +} + +// 创建节点 +type AdminCreateNodeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + ClusterId int64 `protobuf:"varint,2,opt,name=clusterId,proto3" json:"clusterId,omitempty"` +} + +func (x *AdminCreateNodeRequest) Reset() { + *x = AdminCreateNodeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCreateNodeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCreateNodeRequest) ProtoMessage() {} + +func (x *AdminCreateNodeRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[10] + 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 AdminCreateNodeRequest.ProtoReflect.Descriptor instead. +func (*AdminCreateNodeRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{10} +} + +func (x *AdminCreateNodeRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *AdminCreateNodeRequest) GetClusterId() int64 { + if x != nil { + return x.ClusterId + } + return 0 +} + +type AdminCreateNodeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId int64 `protobuf:"varint,1,opt,name=nodeId,proto3" json:"nodeId,omitempty"` +} + +func (x *AdminCreateNodeResponse) Reset() { + *x = AdminCreateNodeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCreateNodeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCreateNodeResponse) ProtoMessage() {} + +func (x *AdminCreateNodeResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[11] + 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 AdminCreateNodeResponse.ProtoReflect.Descriptor instead. +func (*AdminCreateNodeResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{11} +} + +func (x *AdminCreateNodeResponse) GetNodeId() int64 { + if x != nil { + return x.NodeId + } + return 0 +} + +// 节点数量 +type AdminCountAllEnabledNodesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *AdminCountAllEnabledNodesRequest) Reset() { + *x = AdminCountAllEnabledNodesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCountAllEnabledNodesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCountAllEnabledNodesRequest) ProtoMessage() {} + +func (x *AdminCountAllEnabledNodesRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[12] + 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 AdminCountAllEnabledNodesRequest.ProtoReflect.Descriptor instead. +func (*AdminCountAllEnabledNodesRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{12} +} + +type AdminCountAllEnabledNodesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *AdminCountAllEnabledNodesResponse) Reset() { + *x = AdminCountAllEnabledNodesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminCountAllEnabledNodesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminCountAllEnabledNodesResponse) ProtoMessage() {} + +func (x *AdminCountAllEnabledNodesResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[13] + 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 AdminCountAllEnabledNodesResponse.ProtoReflect.Descriptor instead. +func (*AdminCountAllEnabledNodesResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{13} +} + +func (x *AdminCountAllEnabledNodesResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + +// 列出单页节点 +type AdminListEnabledNodesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Offset int64 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"` + Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` +} + +func (x *AdminListEnabledNodesRequest) Reset() { + *x = AdminListEnabledNodesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminListEnabledNodesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminListEnabledNodesRequest) ProtoMessage() {} + +func (x *AdminListEnabledNodesRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[14] + 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 AdminListEnabledNodesRequest.ProtoReflect.Descriptor instead. +func (*AdminListEnabledNodesRequest) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{14} +} + +func (x *AdminListEnabledNodesRequest) GetOffset() int64 { + if x != nil { + return x.Offset + } + return 0 +} + +func (x *AdminListEnabledNodesRequest) GetSize() int64 { + if x != nil { + return x.Size + } + return 0 +} + +type AdminListEnabledNodesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"` +} + +func (x *AdminListEnabledNodesResponse) Reset() { + *x = AdminListEnabledNodesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_admin_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AdminListEnabledNodesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AdminListEnabledNodesResponse) ProtoMessage() {} + +func (x *AdminListEnabledNodesResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_admin_proto_msgTypes[15] + 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 AdminListEnabledNodesResponse.ProtoReflect.Descriptor instead. +func (*AdminListEnabledNodesResponse) Descriptor() ([]byte, []int) { + return file_service_admin_proto_rawDescGZIP(), []int{15} +} + +func (x *AdminListEnabledNodesResponse) GetNodes() []*Node { + if x != nil { + return x.Nodes + } + return nil +} + +var File_service_admin_proto protoreflect.FileDescriptor + +var file_service_admin_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x13, 0x6d, 0x6f, 0x64, 0x65, 0x6c, + 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x10, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x4b, 0x0a, 0x11, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x5c, 0x0a, + 0x12, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, + 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x77, 0x0a, 0x15, 0x41, + 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x70, 0x22, 0x2c, 0x0a, 0x16, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, + 0x4f, 0x6b, 0x22, 0x38, 0x0a, 0x1c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x22, 0x4d, 0x0a, 0x1d, + 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, + 0x78, 0x69, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, + 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x35, 0x0a, 0x19, 0x41, + 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4e, 0x61, 0x6d, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d, 0x69, + 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, + 0x49, 0x64, 0x22, 0x38, 0x0a, 0x1a, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, 0x41, + 0x64, 0x6d, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x24, 0x0a, 0x22, + 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x64, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0x4e, 0x0a, 0x23, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, 0x41, + 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x08, 0x63, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, + 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x08, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x73, 0x22, 0x4a, 0x0a, 0x16, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x22, 0x31, + 0x0a, 0x17, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, + 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, + 0x64, 0x22, 0x22, 0x0a, 0x20, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, + 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x39, 0x0a, 0x21, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x22, 0x4a, 0x0a, 0x1c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x3f, 0x0a, 0x1d, + 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, + 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, + 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x32, 0xb7, 0x05, + 0x0a, 0x0c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x38, + 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x15, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, + 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x59, + 0x0a, 0x10, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, + 0x74, 0x73, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x11, 0x66, 0x69, 0x6e, + 0x64, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, + 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x6d, + 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, + 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x6d, 0x69, + 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x6b, 0x0a, 0x16, 0x66, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x73, 0x12, 0x26, 0x2e, 0x70, 0x62, 0x2e, 0x41, + 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x64, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x46, 0x69, 0x6e, 0x64, + 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0a, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, + 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, + 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x14, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, + 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x24, 0x2e, + 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, + 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x59, 0x0a, 0x10, + 0x6c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, + 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x45, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x69, 0x73, + 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_service_admin_proto_rawDescOnce sync.Once + file_service_admin_proto_rawDescData = file_service_admin_proto_rawDesc +) + +func file_service_admin_proto_rawDescGZIP() []byte { + file_service_admin_proto_rawDescOnce.Do(func() { + file_service_admin_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_admin_proto_rawDescData) + }) + return file_service_admin_proto_rawDescData +} + +var file_service_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_service_admin_proto_goTypes = []interface{}{ + (*AdminLoginRequest)(nil), // 0: pb.AdminLoginRequest + (*AdminLoginResponse)(nil), // 1: pb.AdminLoginResponse + (*AdminCreateLogRequest)(nil), // 2: pb.AdminCreateLogRequest + (*AdminCreateLogResponse)(nil), // 3: pb.AdminCreateLogResponse + (*AdminCheckAdminExistsRequest)(nil), // 4: pb.AdminCheckAdminExistsRequest + (*AdminCheckAdminExistsResponse)(nil), // 5: pb.AdminCheckAdminExistsResponse + (*AdminFindAdminNameRequest)(nil), // 6: pb.AdminFindAdminNameRequest + (*AdminFindAdminNameResponse)(nil), // 7: pb.AdminFindAdminNameResponse + (*AdminFindAllEnabledClustersRequest)(nil), // 8: pb.AdminFindAllEnabledClustersRequest + (*AdminFindAllEnabledClustersResponse)(nil), // 9: pb.AdminFindAllEnabledClustersResponse + (*AdminCreateNodeRequest)(nil), // 10: pb.AdminCreateNodeRequest + (*AdminCreateNodeResponse)(nil), // 11: pb.AdminCreateNodeResponse + (*AdminCountAllEnabledNodesRequest)(nil), // 12: pb.AdminCountAllEnabledNodesRequest + (*AdminCountAllEnabledNodesResponse)(nil), // 13: pb.AdminCountAllEnabledNodesResponse + (*AdminListEnabledNodesRequest)(nil), // 14: pb.AdminListEnabledNodesRequest + (*AdminListEnabledNodesResponse)(nil), // 15: pb.AdminListEnabledNodesResponse + (*Cluster)(nil), // 16: pb.Cluster + (*Node)(nil), // 17: pb.Node +} +var file_service_admin_proto_depIdxs = []int32{ + 16, // 0: pb.AdminFindAllEnabledClustersResponse.clusters:type_name -> pb.Cluster + 17, // 1: pb.AdminListEnabledNodesResponse.nodes:type_name -> pb.Node + 0, // 2: pb.AdminService.login:input_type -> pb.AdminLoginRequest + 2, // 3: pb.AdminService.createLog:input_type -> pb.AdminCreateLogRequest + 4, // 4: pb.AdminService.checkAdminExists:input_type -> pb.AdminCheckAdminExistsRequest + 6, // 5: pb.AdminService.findAdminFullname:input_type -> pb.AdminFindAdminNameRequest + 8, // 6: pb.AdminService.findAllEnabledClusters:input_type -> pb.AdminFindAllEnabledClustersRequest + 10, // 7: pb.AdminService.createNode:input_type -> pb.AdminCreateNodeRequest + 12, // 8: pb.AdminService.countAllEnabledNodes:input_type -> pb.AdminCountAllEnabledNodesRequest + 14, // 9: pb.AdminService.listEnabledNodes:input_type -> pb.AdminListEnabledNodesRequest + 1, // 10: pb.AdminService.login:output_type -> pb.AdminLoginResponse + 3, // 11: pb.AdminService.createLog:output_type -> pb.AdminCreateLogResponse + 5, // 12: pb.AdminService.checkAdminExists:output_type -> pb.AdminCheckAdminExistsResponse + 7, // 13: pb.AdminService.findAdminFullname:output_type -> pb.AdminFindAdminNameResponse + 9, // 14: pb.AdminService.findAllEnabledClusters:output_type -> pb.AdminFindAllEnabledClustersResponse + 11, // 15: pb.AdminService.createNode:output_type -> pb.AdminCreateNodeResponse + 13, // 16: pb.AdminService.countAllEnabledNodes:output_type -> pb.AdminCountAllEnabledNodesResponse + 15, // 17: pb.AdminService.listEnabledNodes:output_type -> pb.AdminListEnabledNodesResponse + 10, // [10:18] is the sub-list for method output_type + 2, // [2:10] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_service_admin_proto_init() } +func file_service_admin_proto_init() { + if File_service_admin_proto != nil { + return + } + file_model_cluster_proto_init() + file_model_node_proto_init() + if !protoimpl.UnsafeEnabled { + file_service_admin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminLoginRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminLoginResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCreateLogRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCreateLogResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCheckAdminExistsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCheckAdminExistsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminFindAdminNameRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminFindAdminNameResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminFindAllEnabledClustersRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminFindAllEnabledClustersResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCreateNodeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCreateNodeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCountAllEnabledNodesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminCountAllEnabledNodesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminListEnabledNodesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_admin_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AdminListEnabledNodesResponse); 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_service_admin_proto_rawDesc, + NumEnums: 0, + NumMessages: 16, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_service_admin_proto_goTypes, + DependencyIndexes: file_service_admin_proto_depIdxs, + MessageInfos: file_service_admin_proto_msgTypes, + }.Build() + File_service_admin_proto = out.File + file_service_admin_proto_rawDesc = nil + file_service_admin_proto_goTypes = nil + file_service_admin_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 + +// AdminServiceClient is the client API for AdminService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type AdminServiceClient interface { + // 登录 + Login(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*AdminLoginResponse, error) + // 创建操作日志 + CreateLog(ctx context.Context, in *AdminCreateLogRequest, opts ...grpc.CallOption) (*AdminCreateLogResponse, error) + // 检查管理员是否存在 + CheckAdminExists(ctx context.Context, in *AdminCheckAdminExistsRequest, opts ...grpc.CallOption) (*AdminCheckAdminExistsResponse, error) + // 获取管理员名称 + FindAdminFullname(ctx context.Context, in *AdminFindAdminNameRequest, opts ...grpc.CallOption) (*AdminFindAdminNameResponse, error) + // 获取所有集群的信息 + FindAllEnabledClusters(ctx context.Context, in *AdminFindAllEnabledClustersRequest, opts ...grpc.CallOption) (*AdminFindAllEnabledClustersResponse, error) + // 创建节点 + CreateNode(ctx context.Context, in *AdminCreateNodeRequest, opts ...grpc.CallOption) (*AdminCreateNodeResponse, error) + // 节点数量 + CountAllEnabledNodes(ctx context.Context, in *AdminCountAllEnabledNodesRequest, opts ...grpc.CallOption) (*AdminCountAllEnabledNodesResponse, error) + // 列出单页节点 + ListEnabledNodes(ctx context.Context, in *AdminListEnabledNodesRequest, opts ...grpc.CallOption) (*AdminListEnabledNodesResponse, error) +} + +type adminServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewAdminServiceClient(cc grpc.ClientConnInterface) AdminServiceClient { + return &adminServiceClient{cc} +} + +func (c *adminServiceClient) Login(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*AdminLoginResponse, error) { + out := new(AdminLoginResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/login", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) CreateLog(ctx context.Context, in *AdminCreateLogRequest, opts ...grpc.CallOption) (*AdminCreateLogResponse, error) { + out := new(AdminCreateLogResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/createLog", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) CheckAdminExists(ctx context.Context, in *AdminCheckAdminExistsRequest, opts ...grpc.CallOption) (*AdminCheckAdminExistsResponse, error) { + out := new(AdminCheckAdminExistsResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/checkAdminExists", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) FindAdminFullname(ctx context.Context, in *AdminFindAdminNameRequest, opts ...grpc.CallOption) (*AdminFindAdminNameResponse, error) { + out := new(AdminFindAdminNameResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/findAdminFullname", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) FindAllEnabledClusters(ctx context.Context, in *AdminFindAllEnabledClustersRequest, opts ...grpc.CallOption) (*AdminFindAllEnabledClustersResponse, error) { + out := new(AdminFindAllEnabledClustersResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/findAllEnabledClusters", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) CreateNode(ctx context.Context, in *AdminCreateNodeRequest, opts ...grpc.CallOption) (*AdminCreateNodeResponse, error) { + out := new(AdminCreateNodeResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/createNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) CountAllEnabledNodes(ctx context.Context, in *AdminCountAllEnabledNodesRequest, opts ...grpc.CallOption) (*AdminCountAllEnabledNodesResponse, error) { + out := new(AdminCountAllEnabledNodesResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/countAllEnabledNodes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminServiceClient) ListEnabledNodes(ctx context.Context, in *AdminListEnabledNodesRequest, opts ...grpc.CallOption) (*AdminListEnabledNodesResponse, error) { + out := new(AdminListEnabledNodesResponse) + err := c.cc.Invoke(ctx, "/pb.AdminService/listEnabledNodes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AdminServiceServer is the server API for AdminService service. +type AdminServiceServer interface { + // 登录 + Login(context.Context, *AdminLoginRequest) (*AdminLoginResponse, error) + // 创建操作日志 + CreateLog(context.Context, *AdminCreateLogRequest) (*AdminCreateLogResponse, error) + // 检查管理员是否存在 + CheckAdminExists(context.Context, *AdminCheckAdminExistsRequest) (*AdminCheckAdminExistsResponse, error) + // 获取管理员名称 + FindAdminFullname(context.Context, *AdminFindAdminNameRequest) (*AdminFindAdminNameResponse, error) + // 获取所有集群的信息 + FindAllEnabledClusters(context.Context, *AdminFindAllEnabledClustersRequest) (*AdminFindAllEnabledClustersResponse, error) + // 创建节点 + CreateNode(context.Context, *AdminCreateNodeRequest) (*AdminCreateNodeResponse, error) + // 节点数量 + CountAllEnabledNodes(context.Context, *AdminCountAllEnabledNodesRequest) (*AdminCountAllEnabledNodesResponse, error) + // 列出单页节点 + ListEnabledNodes(context.Context, *AdminListEnabledNodesRequest) (*AdminListEnabledNodesResponse, error) +} + +// UnimplementedAdminServiceServer can be embedded to have forward compatible implementations. +type UnimplementedAdminServiceServer struct { +} + +func (*UnimplementedAdminServiceServer) Login(context.Context, *AdminLoginRequest) (*AdminLoginResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") +} +func (*UnimplementedAdminServiceServer) CreateLog(context.Context, *AdminCreateLogRequest) (*AdminCreateLogResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateLog not implemented") +} +func (*UnimplementedAdminServiceServer) CheckAdminExists(context.Context, *AdminCheckAdminExistsRequest) (*AdminCheckAdminExistsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CheckAdminExists not implemented") +} +func (*UnimplementedAdminServiceServer) FindAdminFullname(context.Context, *AdminFindAdminNameRequest) (*AdminFindAdminNameResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindAdminFullname not implemented") +} +func (*UnimplementedAdminServiceServer) FindAllEnabledClusters(context.Context, *AdminFindAllEnabledClustersRequest) (*AdminFindAllEnabledClustersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindAllEnabledClusters not implemented") +} +func (*UnimplementedAdminServiceServer) CreateNode(context.Context, *AdminCreateNodeRequest) (*AdminCreateNodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateNode not implemented") +} +func (*UnimplementedAdminServiceServer) CountAllEnabledNodes(context.Context, *AdminCountAllEnabledNodesRequest) (*AdminCountAllEnabledNodesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CountAllEnabledNodes not implemented") +} +func (*UnimplementedAdminServiceServer) ListEnabledNodes(context.Context, *AdminListEnabledNodesRequest) (*AdminListEnabledNodesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEnabledNodes not implemented") +} + +func RegisterAdminServiceServer(s *grpc.Server, srv AdminServiceServer) { + s.RegisterService(&_AdminService_serviceDesc, srv) +} + +func _AdminService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminLoginRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).Login(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/Login", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).Login(ctx, req.(*AdminLoginRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_CreateLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminCreateLogRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).CreateLog(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/CreateLog", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).CreateLog(ctx, req.(*AdminCreateLogRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_CheckAdminExists_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminCheckAdminExistsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).CheckAdminExists(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/CheckAdminExists", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).CheckAdminExists(ctx, req.(*AdminCheckAdminExistsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_FindAdminFullname_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminFindAdminNameRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).FindAdminFullname(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/FindAdminFullname", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).FindAdminFullname(ctx, req.(*AdminFindAdminNameRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_FindAllEnabledClusters_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminFindAllEnabledClustersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).FindAllEnabledClusters(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/FindAllEnabledClusters", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).FindAllEnabledClusters(ctx, req.(*AdminFindAllEnabledClustersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_CreateNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminCreateNodeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).CreateNode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/CreateNode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).CreateNode(ctx, req.(*AdminCreateNodeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_CountAllEnabledNodes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminCountAllEnabledNodesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).CountAllEnabledNodes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/CountAllEnabledNodes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).CountAllEnabledNodes(ctx, req.(*AdminCountAllEnabledNodesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AdminService_ListEnabledNodes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminListEnabledNodesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServiceServer).ListEnabledNodes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.AdminService/ListEnabledNodes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServiceServer).ListEnabledNodes(ctx, req.(*AdminListEnabledNodesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _AdminService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.AdminService", + HandlerType: (*AdminServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "login", + Handler: _AdminService_Login_Handler, + }, + { + MethodName: "createLog", + Handler: _AdminService_CreateLog_Handler, + }, + { + MethodName: "checkAdminExists", + Handler: _AdminService_CheckAdminExists_Handler, + }, + { + MethodName: "findAdminFullname", + Handler: _AdminService_FindAdminFullname_Handler, + }, + { + MethodName: "findAllEnabledClusters", + Handler: _AdminService_FindAllEnabledClusters_Handler, + }, + { + MethodName: "createNode", + Handler: _AdminService_CreateNode_Handler, + }, + { + MethodName: "countAllEnabledNodes", + Handler: _AdminService_CountAllEnabledNodes_Handler, + }, + { + MethodName: "listEnabledNodes", + Handler: _AdminService_ListEnabledNodes_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "service_admin.proto", +} diff --git a/internal/rpc/dns/service.pb.go b/internal/rpc/pb/service_dns.pb.go similarity index 51% rename from internal/rpc/dns/service.pb.go rename to internal/rpc/pb/service_dns.pb.go index a9e723a5..e3a1e329 100644 --- a/internal/rpc/dns/service.pb.go +++ b/internal/rpc/pb/service_dns.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.12.3 -// source: dns/service.proto +// source: service_dns.proto -package dns +package pb import ( context "context" @@ -26,17 +26,17 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -var File_dns_service_proto protoreflect.FileDescriptor +var File_service_dns_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_service_dns_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x64, 0x6e, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x32, 0x0c, 0x0a, 0x0a, 0x44, 0x6e, 0x73, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_dns_service_proto_goTypes = []interface{}{} -var file_dns_service_proto_depIdxs = []int32{ +var file_service_dns_proto_goTypes = []interface{}{} +var file_service_dns_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 @@ -44,28 +44,28 @@ var file_dns_service_proto_depIdxs = []int32{ 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 { +func init() { file_service_dns_proto_init() } +func file_service_dns_proto_init() { + if File_service_dns_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_dns_service_proto_rawDesc, + RawDescriptor: file_service_dns_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_dns_service_proto_goTypes, - DependencyIndexes: file_dns_service_proto_depIdxs, + GoTypes: file_service_dns_proto_goTypes, + DependencyIndexes: file_service_dns_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 + File_service_dns_proto = out.File + file_service_dns_proto_rawDesc = nil + file_service_dns_proto_goTypes = nil + file_service_dns_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -76,36 +76,36 @@ var _ grpc.ClientConnInterface // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion6 -// ServiceClient is the client API for Service service. +// DnsServiceClient is the client API for DnsService 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 DnsServiceClient interface { } -type serviceClient struct { +type dnsServiceClient struct { cc grpc.ClientConnInterface } -func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { - return &serviceClient{cc} +func NewDnsServiceClient(cc grpc.ClientConnInterface) DnsServiceClient { + return &dnsServiceClient{cc} } -// ServiceServer is the server API for Service service. -type ServiceServer interface { +// DnsServiceServer is the server API for DnsService service. +type DnsServiceServer interface { } -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { +// UnimplementedDnsServiceServer can be embedded to have forward compatible implementations. +type UnimplementedDnsServiceServer struct { } -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) +func RegisterDnsServiceServer(s *grpc.Server, srv DnsServiceServer) { + s.RegisterService(&_DnsService_serviceDesc, srv) } -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "dns.Service", - HandlerType: (*ServiceServer)(nil), +var _DnsService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.DnsService", + HandlerType: (*DnsServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{}, - Metadata: "dns/service.proto", + Metadata: "service_dns.proto", } diff --git a/internal/rpc/log/service.pb.go b/internal/rpc/pb/service_log.pb.go similarity index 51% rename from internal/rpc/log/service.pb.go rename to internal/rpc/pb/service_log.pb.go index 526c9390..f469b5d5 100644 --- a/internal/rpc/log/service.pb.go +++ b/internal/rpc/pb/service_log.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.12.3 -// source: log/service.proto +// source: service_log.proto -package log +package pb import ( context "context" @@ -26,17 +26,17 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -var File_log_service_proto protoreflect.FileDescriptor +var File_service_log_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_service_log_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x32, 0x0c, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_log_service_proto_goTypes = []interface{}{} -var file_log_service_proto_depIdxs = []int32{ +var file_service_log_proto_goTypes = []interface{}{} +var file_service_log_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 @@ -44,28 +44,28 @@ var file_log_service_proto_depIdxs = []int32{ 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 { +func init() { file_service_log_proto_init() } +func file_service_log_proto_init() { + if File_service_log_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_log_service_proto_rawDesc, + RawDescriptor: file_service_log_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_log_service_proto_goTypes, - DependencyIndexes: file_log_service_proto_depIdxs, + GoTypes: file_service_log_proto_goTypes, + DependencyIndexes: file_service_log_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 + File_service_log_proto = out.File + file_service_log_proto_rawDesc = nil + file_service_log_proto_goTypes = nil + file_service_log_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -76,36 +76,36 @@ var _ grpc.ClientConnInterface // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion6 -// ServiceClient is the client API for Service service. +// LogServiceClient is the client API for LogService 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 LogServiceClient interface { } -type serviceClient struct { +type logServiceClient struct { cc grpc.ClientConnInterface } -func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { - return &serviceClient{cc} +func NewLogServiceClient(cc grpc.ClientConnInterface) LogServiceClient { + return &logServiceClient{cc} } -// ServiceServer is the server API for Service service. -type ServiceServer interface { +// LogServiceServer is the server API for LogService service. +type LogServiceServer interface { } -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { +// UnimplementedLogServiceServer can be embedded to have forward compatible implementations. +type UnimplementedLogServiceServer struct { } -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) +func RegisterLogServiceServer(s *grpc.Server, srv LogServiceServer) { + s.RegisterService(&_LogService_serviceDesc, srv) } -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "log.Service", - HandlerType: (*ServiceServer)(nil), +var _LogService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.LogService", + HandlerType: (*LogServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{}, - Metadata: "log/service.proto", + Metadata: "service_log.proto", } diff --git a/internal/rpc/pb/service_monitor.pb.go b/internal/rpc/pb/service_monitor.pb.go new file mode 100644 index 00000000..514233f7 --- /dev/null +++ b/internal/rpc/pb/service_monitor.pb.go @@ -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: service_monitor.proto + +package pb + +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_service_monitor_proto protoreflect.FileDescriptor + +var file_service_monitor_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, + 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x32, 0x10, 0x0a, 0x0e, 0x4d, + 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_service_monitor_proto_goTypes = []interface{}{} +var file_service_monitor_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_service_monitor_proto_init() } +func file_service_monitor_proto_init() { + if File_service_monitor_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_service_monitor_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_service_monitor_proto_goTypes, + DependencyIndexes: file_service_monitor_proto_depIdxs, + }.Build() + File_service_monitor_proto = out.File + file_service_monitor_proto_rawDesc = nil + file_service_monitor_proto_goTypes = nil + file_service_monitor_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 + +// MonitorServiceClient is the client API for MonitorService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MonitorServiceClient interface { +} + +type monitorServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewMonitorServiceClient(cc grpc.ClientConnInterface) MonitorServiceClient { + return &monitorServiceClient{cc} +} + +// MonitorServiceServer is the server API for MonitorService service. +type MonitorServiceServer interface { +} + +// UnimplementedMonitorServiceServer can be embedded to have forward compatible implementations. +type UnimplementedMonitorServiceServer struct { +} + +func RegisterMonitorServiceServer(s *grpc.Server, srv MonitorServiceServer) { + s.RegisterService(&_MonitorService_serviceDesc, srv) +} + +var _MonitorService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.MonitorService", + HandlerType: (*MonitorServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "service_monitor.proto", +} diff --git a/internal/rpc/node/service.pb.go b/internal/rpc/pb/service_node.pb.go similarity index 54% rename from internal/rpc/node/service.pb.go rename to internal/rpc/pb/service_node.pb.go index 629cd5bf..a685e042 100644 --- a/internal/rpc/node/service.pb.go +++ b/internal/rpc/pb/service_node.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.12.3 -// source: node/service.proto +// source: service_node.proto -package node +package pb import ( context "context" @@ -40,7 +40,7 @@ type ConfigRequest struct { func (x *ConfigRequest) Reset() { *x = ConfigRequest{} if protoimpl.UnsafeEnabled { - mi := &file_node_service_proto_msgTypes[0] + mi := &file_service_node_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -53,7 +53,7 @@ func (x *ConfigRequest) String() string { func (*ConfigRequest) ProtoMessage() {} func (x *ConfigRequest) ProtoReflect() protoreflect.Message { - mi := &file_node_service_proto_msgTypes[0] + mi := &file_service_node_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -66,7 +66,7 @@ func (x *ConfigRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ConfigRequest.ProtoReflect.Descriptor instead. func (*ConfigRequest) Descriptor() ([]byte, []int) { - return file_node_service_proto_rawDescGZIP(), []int{0} + return file_service_node_proto_rawDescGZIP(), []int{0} } func (x *ConfigRequest) GetNodeId() string { @@ -87,7 +87,7 @@ type ConfigResponse struct { func (x *ConfigResponse) Reset() { *x = ConfigResponse{} if protoimpl.UnsafeEnabled { - mi := &file_node_service_proto_msgTypes[1] + mi := &file_service_node_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -100,7 +100,7 @@ func (x *ConfigResponse) String() string { func (*ConfigResponse) ProtoMessage() {} func (x *ConfigResponse) ProtoReflect() protoreflect.Message { - mi := &file_node_service_proto_msgTypes[1] + mi := &file_service_node_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -113,7 +113,7 @@ func (x *ConfigResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ConfigResponse.ProtoReflect.Descriptor instead. func (*ConfigResponse) Descriptor() ([]byte, []int) { - return file_node_service_proto_rawDescGZIP(), []int{1} + return file_service_node_proto_rawDescGZIP(), []int{1} } func (x *ConfigResponse) GetId() string { @@ -123,43 +123,43 @@ func (x *ConfigResponse) GetId() string { return "" } -var File_node_service_proto protoreflect.FileDescriptor +var File_service_node_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, 0x27, 0x0a, 0x0d, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, - 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, - 0x65, 0x49, 0x64, 0x22, 0x20, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x32, 0x40, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x35, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x13, 0x2e, 0x6e, 0x6f, 0x64, - 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x14, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 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_service_node_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x27, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, + 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, + 0x64, 0x22, 0x20, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x32, 0x40, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x31, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x11, 0x2e, 0x70, + 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 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 + file_service_node_proto_rawDescOnce sync.Once + file_service_node_proto_rawDescData = file_service_node_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) +func file_service_node_proto_rawDescGZIP() []byte { + file_service_node_proto_rawDescOnce.Do(func() { + file_service_node_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_node_proto_rawDescData) }) - return file_node_service_proto_rawDescData + return file_service_node_proto_rawDescData } -var file_node_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_node_service_proto_goTypes = []interface{}{ - (*ConfigRequest)(nil), // 0: node.ConfigRequest - (*ConfigResponse)(nil), // 1: node.ConfigResponse +var file_service_node_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_service_node_proto_goTypes = []interface{}{ + (*ConfigRequest)(nil), // 0: pb.ConfigRequest + (*ConfigResponse)(nil), // 1: pb.ConfigResponse } -var file_node_service_proto_depIdxs = []int32{ - 0, // 0: node.Service.config:input_type -> node.ConfigRequest - 1, // 1: node.Service.config:output_type -> node.ConfigResponse +var file_service_node_proto_depIdxs = []int32{ + 0, // 0: pb.NodeService.config:input_type -> pb.ConfigRequest + 1, // 1: pb.NodeService.config:output_type -> pb.ConfigResponse 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 @@ -167,13 +167,13 @@ var file_node_service_proto_depIdxs = []int32{ 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 { +func init() { file_service_node_proto_init() } +func file_service_node_proto_init() { + if File_service_node_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_node_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_service_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ConfigRequest); i { case 0: return &v.state @@ -185,7 +185,7 @@ func file_node_service_proto_init() { return nil } } - file_node_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_service_node_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ConfigResponse); i { case 0: return &v.state @@ -202,20 +202,20 @@ func file_node_service_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_node_service_proto_rawDesc, + RawDescriptor: file_service_node_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, + GoTypes: file_service_node_proto_goTypes, + DependencyIndexes: file_service_node_proto_depIdxs, + MessageInfos: file_service_node_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 + File_service_node_proto = out.File + file_service_node_proto_rawDesc = nil + file_service_node_proto_goTypes = nil + file_service_node_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -226,74 +226,74 @@ var _ grpc.ClientConnInterface // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion6 -// ServiceClient is the client API for Service service. +// NodeServiceClient is the client API for NodeService 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 NodeServiceClient interface { Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) } -type serviceClient struct { +type nodeServiceClient struct { cc grpc.ClientConnInterface } -func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { - return &serviceClient{cc} +func NewNodeServiceClient(cc grpc.ClientConnInterface) NodeServiceClient { + return &nodeServiceClient{cc} } -func (c *serviceClient) Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) { +func (c *nodeServiceClient) Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) { out := new(ConfigResponse) - err := c.cc.Invoke(ctx, "/node.Service/config", in, out, opts...) + err := c.cc.Invoke(ctx, "/pb.NodeService/config", in, out, opts...) if err != nil { return nil, err } return out, nil } -// ServiceServer is the server API for Service service. -type ServiceServer interface { +// NodeServiceServer is the server API for NodeService service. +type NodeServiceServer interface { Config(context.Context, *ConfigRequest) (*ConfigResponse, error) } -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { +// UnimplementedNodeServiceServer can be embedded to have forward compatible implementations. +type UnimplementedNodeServiceServer struct { } -func (*UnimplementedServiceServer) Config(context.Context, *ConfigRequest) (*ConfigResponse, error) { +func (*UnimplementedNodeServiceServer) Config(context.Context, *ConfigRequest) (*ConfigResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") } -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) +func RegisterNodeServiceServer(s *grpc.Server, srv NodeServiceServer) { + s.RegisterService(&_NodeService_serviceDesc, srv) } -func _Service_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _NodeService_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ConfigRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ServiceServer).Config(ctx, in) + return srv.(NodeServiceServer).Config(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Service/Config", + FullMethod: "/pb.NodeService/Config", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Config(ctx, req.(*ConfigRequest)) + return srv.(NodeServiceServer).Config(ctx, req.(*ConfigRequest)) } return interceptor(ctx, in, info, handler) } -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "node.Service", - HandlerType: (*ServiceServer)(nil), +var _NodeService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.NodeService", + HandlerType: (*NodeServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "config", - Handler: _Service_Config_Handler, + Handler: _NodeService_Config_Handler, }, }, Streams: []grpc.StreamDesc{}, - Metadata: "node/service.proto", + Metadata: "service_node.proto", } diff --git a/internal/rpc/pb/service_provider.pb.go b/internal/rpc/pb/service_provider.pb.go new file mode 100644 index 00000000..2ba0b116 --- /dev/null +++ b/internal/rpc/pb/service_provider.pb.go @@ -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: service_provider.proto + +package pb + +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_service_provider_proto protoreflect.FileDescriptor + +var file_service_provider_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x32, 0x11, 0x0a, 0x0f, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_service_provider_proto_goTypes = []interface{}{} +var file_service_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_service_provider_proto_init() } +func file_service_provider_proto_init() { + if File_service_provider_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_service_provider_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_service_provider_proto_goTypes, + DependencyIndexes: file_service_provider_proto_depIdxs, + }.Build() + File_service_provider_proto = out.File + file_service_provider_proto_rawDesc = nil + file_service_provider_proto_goTypes = nil + file_service_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 + +// ProviderServiceClient is the client API for ProviderService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ProviderServiceClient interface { +} + +type providerServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewProviderServiceClient(cc grpc.ClientConnInterface) ProviderServiceClient { + return &providerServiceClient{cc} +} + +// ProviderServiceServer is the server API for ProviderService service. +type ProviderServiceServer interface { +} + +// UnimplementedProviderServiceServer can be embedded to have forward compatible implementations. +type UnimplementedProviderServiceServer struct { +} + +func RegisterProviderServiceServer(s *grpc.Server, srv ProviderServiceServer) { + s.RegisterService(&_ProviderService_serviceDesc, srv) +} + +var _ProviderService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.ProviderService", + HandlerType: (*ProviderServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "service_provider.proto", +} diff --git a/internal/rpc/stat/service.pb.go b/internal/rpc/pb/service_stat.pb.go similarity index 52% rename from internal/rpc/stat/service.pb.go rename to internal/rpc/pb/service_stat.pb.go index d5320334..09c7961b 100644 --- a/internal/rpc/stat/service.pb.go +++ b/internal/rpc/pb/service_stat.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.12.3 -// source: stat/service.proto +// source: service_stat.proto -package stat +package pb import ( context "context" @@ -26,17 +26,17 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -var File_stat_service_proto protoreflect.FileDescriptor +var File_service_stat_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, +var file_service_stat_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x32, 0x0d, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x74, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_stat_service_proto_goTypes = []interface{}{} -var file_stat_service_proto_depIdxs = []int32{ +var file_service_stat_proto_goTypes = []interface{}{} +var file_service_stat_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 @@ -44,28 +44,28 @@ var file_stat_service_proto_depIdxs = []int32{ 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 { +func init() { file_service_stat_proto_init() } +func file_service_stat_proto_init() { + if File_service_stat_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_stat_service_proto_rawDesc, + RawDescriptor: file_service_stat_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_stat_service_proto_goTypes, - DependencyIndexes: file_stat_service_proto_depIdxs, + GoTypes: file_service_stat_proto_goTypes, + DependencyIndexes: file_service_stat_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 + File_service_stat_proto = out.File + file_service_stat_proto_rawDesc = nil + file_service_stat_proto_goTypes = nil + file_service_stat_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -76,36 +76,36 @@ var _ grpc.ClientConnInterface // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion6 -// ServiceClient is the client API for Service service. +// StatServiceClient is the client API for StatService 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 StatServiceClient interface { } -type serviceClient struct { +type statServiceClient struct { cc grpc.ClientConnInterface } -func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { - return &serviceClient{cc} +func NewStatServiceClient(cc grpc.ClientConnInterface) StatServiceClient { + return &statServiceClient{cc} } -// ServiceServer is the server API for Service service. -type ServiceServer interface { +// StatServiceServer is the server API for StatService service. +type StatServiceServer interface { } -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { +// UnimplementedStatServiceServer can be embedded to have forward compatible implementations. +type UnimplementedStatServiceServer struct { } -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) +func RegisterStatServiceServer(s *grpc.Server, srv StatServiceServer) { + s.RegisterService(&_StatService_serviceDesc, srv) } -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "stat.Service", - HandlerType: (*ServiceServer)(nil), +var _StatService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.StatService", + HandlerType: (*StatServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{}, - Metadata: "stat/service.proto", + Metadata: "service_stat.proto", } diff --git a/internal/rpc/user/service.pb.go b/internal/rpc/pb/service_user.pb.go similarity index 52% rename from internal/rpc/user/service.pb.go rename to internal/rpc/pb/service_user.pb.go index f440699a..82f62cc9 100644 --- a/internal/rpc/user/service.pb.go +++ b/internal/rpc/pb/service_user.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0 // protoc v3.12.3 -// source: user/service.proto +// source: service_user.proto -package user +package pb import ( context "context" @@ -26,17 +26,17 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 -var File_user_service_proto protoreflect.FileDescriptor +var File_service_user_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, +var file_service_user_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x32, 0x0d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var file_user_service_proto_goTypes = []interface{}{} -var file_user_service_proto_depIdxs = []int32{ +var file_service_user_proto_goTypes = []interface{}{} +var file_service_user_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 @@ -44,28 +44,28 @@ var file_user_service_proto_depIdxs = []int32{ 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 { +func init() { file_service_user_proto_init() } +func file_service_user_proto_init() { + if File_service_user_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_user_service_proto_rawDesc, + RawDescriptor: file_service_user_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_user_service_proto_goTypes, - DependencyIndexes: file_user_service_proto_depIdxs, + GoTypes: file_service_user_proto_goTypes, + DependencyIndexes: file_service_user_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 + File_service_user_proto = out.File + file_service_user_proto_rawDesc = nil + file_service_user_proto_goTypes = nil + file_service_user_proto_depIdxs = nil } // Reference imports to suppress errors if they are not otherwise used. @@ -76,36 +76,36 @@ var _ grpc.ClientConnInterface // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion6 -// ServiceClient is the client API for Service service. +// UserServiceClient is the client API for UserService 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 UserServiceClient interface { } -type serviceClient struct { +type userServiceClient struct { cc grpc.ClientConnInterface } -func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { - return &serviceClient{cc} +func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { + return &userServiceClient{cc} } -// ServiceServer is the server API for Service service. -type ServiceServer interface { +// UserServiceServer is the server API for UserService service. +type UserServiceServer interface { } -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { +// UnimplementedUserServiceServer can be embedded to have forward compatible implementations. +type UnimplementedUserServiceServer struct { } -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) +func RegisterUserServiceServer(s *grpc.Server, srv UserServiceServer) { + s.RegisterService(&_UserService_serviceDesc, srv) } -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "user.Service", - HandlerType: (*ServiceServer)(nil), +var _UserService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "pb.UserService", + HandlerType: (*UserServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{}, - Metadata: "user/service.proto", + Metadata: "service_user.proto", } diff --git a/internal/rpc/protos/model_cluster.proto b/internal/rpc/protos/model_cluster.proto new file mode 100644 index 00000000..5800489b --- /dev/null +++ b/internal/rpc/protos/model_cluster.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +option go_package = "./pb"; + +package pb; + +message Cluster { + int64 id = 1; + string name = 2; + int64 createdAt = 3; +} \ No newline at end of file diff --git a/internal/rpc/protos/model_node.proto b/internal/rpc/protos/model_node.proto new file mode 100644 index 00000000..1c208e5d --- /dev/null +++ b/internal/rpc/protos/model_node.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +option go_package = "./pb"; + +package pb; + +import "model_cluster.proto"; + +message Node { + int64 id = 1; + string name = 2; + + Cluster cluster = 32; +} \ No newline at end of file diff --git a/internal/rpc/protos/service_admin.proto b/internal/rpc/protos/service_admin.proto new file mode 100644 index 00000000..ba9e549e --- /dev/null +++ b/internal/rpc/protos/service_admin.proto @@ -0,0 +1,119 @@ +syntax = "proto3"; +option go_package = "./pb"; + +package pb; + +import "model_cluster.proto"; +import "model_node.proto"; + +service AdminService { + // 登录 + rpc login (AdminLoginRequest) returns (AdminLoginResponse) { + } + + // 创建操作日志 + rpc createLog (AdminCreateLogRequest) returns (AdminCreateLogResponse) { + } + + // 检查管理员是否存在 + rpc checkAdminExists (AdminCheckAdminExistsRequest) returns (AdminCheckAdminExistsResponse) { + } + + // 获取管理员名称 + rpc findAdminFullname (AdminFindAdminNameRequest) returns (AdminFindAdminNameResponse) { + } + + // 获取所有集群的信息 + rpc findAllEnabledClusters (AdminFindAllEnabledClustersRequest) returns (AdminFindAllEnabledClustersResponse) { + } + + // 创建节点 + rpc createNode (AdminCreateNodeRequest) returns (AdminCreateNodeResponse) { + }; + + // 节点数量 + rpc countAllEnabledNodes (AdminCountAllEnabledNodesRequest) returns (AdminCountAllEnabledNodesResponse) { + }; + + // 列出单页节点 + rpc listEnabledNodes (AdminListEnabledNodesRequest) returns (AdminListEnabledNodesResponse) { + + } +} + +message AdminLoginRequest { + string username = 1; + string password = 2; +} + +message AdminLoginResponse { + int64 adminId = 1; + bool isOk = 2; + string message = 3; +} + +message AdminCreateLogRequest { + string level = 1; + string description = 2; + string action = 3; + string ip = 4; +} + +message AdminCreateLogResponse { + bool isOk = 1; +} + +message AdminCheckAdminExistsRequest { + int64 adminId = 1; +} + +message AdminCheckAdminExistsResponse { + bool isOk = 1; + string message = 2; +} + + +message AdminFindAdminNameRequest { + int64 adminId = 1; +} + +message AdminFindAdminNameResponse { + string fullname = 1; +} + +message AdminFindAllEnabledClustersRequest { + +} + +message AdminFindAllEnabledClustersResponse { + repeated Cluster clusters = 1; +} + +// 创建节点 +message AdminCreateNodeRequest { + string name = 1; + int64 clusterId = 2; +} + +message AdminCreateNodeResponse { + int64 nodeId = 1; +} + +// 节点数量 +message AdminCountAllEnabledNodesRequest { + +} + +message AdminCountAllEnabledNodesResponse { + int64 count = 1; +} + +// 列出单页节点 +message AdminListEnabledNodesRequest { + int64 offset = 1; + int64 size = 2; +} + +message AdminListEnabledNodesResponse { + repeated Node nodes = 1; +} \ No newline at end of file diff --git a/internal/rpc/protos/service_dns.proto b/internal/rpc/protos/service_dns.proto new file mode 100644 index 00000000..6871ffe1 --- /dev/null +++ b/internal/rpc/protos/service_dns.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package pb; + +option go_package = "./pb"; + +service DnsService { + +} diff --git a/internal/rpc/protos/service_log.proto b/internal/rpc/protos/service_log.proto new file mode 100644 index 00000000..6849be28 --- /dev/null +++ b/internal/rpc/protos/service_log.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package pb; + +option go_package = "./pb"; + +service LogService { + +} diff --git a/internal/rpc/protos/service_monitor.proto b/internal/rpc/protos/service_monitor.proto new file mode 100644 index 00000000..b2fb4337 --- /dev/null +++ b/internal/rpc/protos/service_monitor.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package pb; + +option go_package = "./pb"; + +service MonitorService { + +} diff --git a/internal/rpc/node/service.proto b/internal/rpc/protos/service_node.proto similarity index 73% rename from internal/rpc/node/service.proto rename to internal/rpc/protos/service_node.proto index e706eb20..513a1fcd 100644 --- a/internal/rpc/node/service.proto +++ b/internal/rpc/protos/service_node.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package node; +package pb; -option go_package = "./node"; +option go_package = "./pb"; -service Service { +service NodeService { rpc config (ConfigRequest) returns (ConfigResponse) { } diff --git a/internal/rpc/protos/service_provider.proto b/internal/rpc/protos/service_provider.proto new file mode 100644 index 00000000..52278485 --- /dev/null +++ b/internal/rpc/protos/service_provider.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package pb; + +option go_package = "./pb"; + +service ProviderService { + +} diff --git a/internal/rpc/protos/service_stat.proto b/internal/rpc/protos/service_stat.proto new file mode 100644 index 00000000..9cb48928 --- /dev/null +++ b/internal/rpc/protos/service_stat.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package pb; + +option go_package = "./pb"; + +service StatService { + +} diff --git a/internal/rpc/protos/service_user.proto b/internal/rpc/protos/service_user.proto new file mode 100644 index 00000000..c729d3cc --- /dev/null +++ b/internal/rpc/protos/service_user.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +option go_package = "./pb"; + +package pb; + +service UserService { + +} diff --git a/internal/rpc/provider/provider.pb.go b/internal/rpc/provider/provider.pb.go deleted file mode 100644 index b9a765b5..00000000 --- a/internal/rpc/provider/provider.pb.go +++ /dev/null @@ -1,112 +0,0 @@ -// 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", -} diff --git a/internal/rpc/provider/provider.proto b/internal/rpc/provider/provider.proto deleted file mode 100644 index 746c1d45..00000000 --- a/internal/rpc/provider/provider.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package provider; - -option go_package = "./provider"; - -service Service { - -} diff --git a/internal/rpc/provider/service.go b/internal/rpc/provider/service.go deleted file mode 100644 index 456bad43..00000000 --- a/internal/rpc/provider/service.go +++ /dev/null @@ -1,4 +0,0 @@ -package provider - -type Service struct { -} diff --git a/internal/rpc/services/service_admin.go b/internal/rpc/services/service_admin.go new file mode 100644 index 00000000..de9b315e --- /dev/null +++ b/internal/rpc/services/service_admin.go @@ -0,0 +1,270 @@ +package services + +import ( + "context" + "encoding/base64" + "encoding/json" + "errors" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" + "github.com/TeaOSLab/EdgeAPI/internal/encrypt" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/pb" + "github.com/TeaOSLab/EdgeAPI/internal/utils" + "github.com/iwind/TeaGo/maps" + "google.golang.org/grpc/metadata" + "time" +) + +type AdminService struct { + debug bool +} + +func (this *AdminService) Login(ctx context.Context, req *pb.AdminLoginRequest) (*pb.AdminLoginResponse, error) { + _, err := this.validateRequest(ctx) + if err != nil { + return nil, err + } + + if len(req.Username) == 0 || len(req.Password) == 0 { + return &pb.AdminLoginResponse{ + AdminId: 0, + IsOk: false, + Message: "请输入正确的用户名密码", + }, nil + } + + adminId, err := models.SharedAdminDAO.CheckAdminPassword(req.Username, req.Password) + if err != nil { + utils.PrintError(err) + return nil, err + } + + if adminId <= 0 { + return &pb.AdminLoginResponse{ + AdminId: 0, + IsOk: false, + Message: "请输入正确的用户名密码", + }, nil + } + + return &pb.AdminLoginResponse{ + AdminId: int64(adminId), + IsOk: true, + }, nil +} + +func (this *AdminService) CreateLog(ctx context.Context, req *pb.AdminCreateLogRequest) (*pb.AdminCreateLogResponse, error) { + adminId, err := this.validateAdminRequest(ctx) + if err != nil { + return nil, err + } + err = models.SharedLogDAO.CreateAdminLog(adminId, req.Level, req.Description, req.Action, req.Ip) + return &pb.AdminCreateLogResponse{ + IsOk: err != nil, + }, err +} + +func (this *AdminService) CheckAdminExists(ctx context.Context, req *pb.AdminCheckAdminExistsRequest) (*pb.AdminCheckAdminExistsResponse, error) { + _, err := this.validateRequest(ctx) + if err != nil { + return nil, err + } + + if req.AdminId <= 0 { + return &pb.AdminCheckAdminExistsResponse{ + IsOk: false, + }, nil + } + + ok, err := models.SharedAdminDAO.ExistEnabledAdmin(int(req.AdminId)) + if err != nil { + return nil, err + } + + return &pb.AdminCheckAdminExistsResponse{ + IsOk: ok, + }, nil +} + +func (this *AdminService) FindAdminFullname(ctx context.Context, req *pb.AdminFindAdminNameRequest) (*pb.AdminFindAdminNameResponse, error) { + _, err := this.validateRequest(ctx) + if err != nil { + return nil, err + } + + fullname, err := models.SharedAdminDAO.FindAdminFullname(int(req.AdminId)) + if err != nil { + utils.PrintError(err) + return nil, err + } + + return &pb.AdminFindAdminNameResponse{ + Fullname: fullname, + }, nil +} + +func (this *AdminService) FindAllEnabledClusters(ctx context.Context, req *pb.AdminFindAllEnabledClustersRequest) (*pb.AdminFindAllEnabledClustersResponse, error) { + _ = req + + _, err := this.validateAdminRequest(ctx) + if err != nil { + return nil, err + } + + clusters, err := models.SharedNodeClusterDAO.FindAllEnableClusters() + if err != nil { + return nil, err + } + + result := []*pb.Cluster{} + for _, cluster := range clusters { + result = append(result, &pb.Cluster{ + Id: int64(cluster.Id), + Name: cluster.Name, + CreatedAt: int64(cluster.CreatedAt), + }) + } + + return &pb.AdminFindAllEnabledClustersResponse{ + Clusters: result, + }, nil +} + +func (this *AdminService) CreateNode(ctx context.Context, req *pb.AdminCreateNodeRequest) (*pb.AdminCreateNodeResponse, error) { + _, err := this.validateAdminRequest(ctx) + if err != nil { + return nil, err + } + + nodeId, err := models.SharedNodeDAO.CreateNode(req.Name, int(req.ClusterId)) + if err != nil { + return nil, err + } + + return &pb.AdminCreateNodeResponse{ + NodeId: int64(nodeId), + }, nil +} + +func (this *AdminService) CountAllEnabledNodes(ctx context.Context, req *pb.AdminCountAllEnabledNodesRequest) (*pb.AdminCountAllEnabledNodesResponse, error) { + _, err := this.validateAdminRequest(ctx) + if err != nil { + return nil, err + } + count, err := models.SharedNodeDAO.CountAllEnabledNodes() + if err != nil { + return nil, err + } + + return &pb.AdminCountAllEnabledNodesResponse{Count: count}, nil +} + +func (this *AdminService) ListEnabledNodes(ctx context.Context, req *pb.AdminListEnabledNodesRequest) (*pb.AdminListEnabledNodesResponse, error) { + _, err := this.validateAdminRequest(ctx) + if err != nil { + return nil, err + } + nodes, err := models.SharedNodeDAO.ListEnabledNodes(req.Offset, req.Size) + if err != nil { + return nil, err + } + result := []*pb.Node{} + for _, node := range nodes { + // 集群信息 + clusterName, err := models.SharedNodeClusterDAO.FindNodeClusterName(int64(node.ClusterId)) + if err != nil { + return nil, err + } + + result = append(result, &pb.Node{ + Id: int64(node.Id), + Name: node.Name, + Cluster: &pb.Cluster{ + Id: int64(node.ClusterId), + Name: clusterName, + }, + }) + } + + return &pb.AdminListEnabledNodesResponse{ + Nodes: result, + }, nil +} + +func (this *AdminService) validateRequest(ctx context.Context) (adminId int, err error) { + var md metadata.MD + var ok bool + if this.debug { + md, ok = metadata.FromOutgoingContext(ctx) + } else { + md, ok = metadata.FromIncomingContext(ctx) + } + if !ok { + return 0, errors.New("context: need 'nodeId'") + } + nodeIds := md.Get("nodeid") + if len(nodeIds) == 0 || len(nodeIds[0]) == 0 { + return 0, errors.New("context: need 'nodeId'") + } + nodeId := nodeIds[0] + + // 获取Node信息 + apiToken, err := models.SharedApiTokenDAO.FindEnabledTokenWithNode(nodeId) + if err != nil { + utils.PrintError(err) + return 0, err + } + if apiToken == nil { + return 0, errors.New("can not find token from node id: " + err.Error()) + } + + tokens := md.Get("token") + if len(tokens) == 0 || len(tokens[0]) == 0 { + return 0, errors.New("context: need 'token'") + } + token := tokens[0] + + data, err := base64.StdEncoding.DecodeString(token) + if err != nil { + return 0, err + } + + method, err := encrypt.NewMethodInstance(teaconst.EncryptMethod, apiToken.Secret, nodeId) + if err != nil { + utils.PrintError(err) + return 0, err + } + data, err = method.Decrypt(data) + if err != nil { + return 0, err + } + if len(data) == 0 { + return 0, errors.New("invalid token") + } + + m := maps.Map{} + err = json.Unmarshal(data, &m) + if err != nil { + return 0, errors.New("decode token error: " + err.Error()) + } + + timestamp := m.GetInt64("timestamp") + if time.Now().Unix()-timestamp > 600 { + // 请求超过10分钟认为超时 + return 0, errors.New("authenticate timeout") + } + + adminId = m.GetInt("adminId") + return +} + +func (this *AdminService) validateAdminRequest(ctx context.Context) (adminId int, err error) { + adminId, err = this.validateRequest(ctx) + if err != nil { + return 0, err + } + if adminId <= 0 { + return 0, errors.New("invalid admin id") + } + return +} diff --git a/internal/rpc/admin/service_test.go b/internal/rpc/services/service_admin_test.go similarity index 67% rename from internal/rpc/admin/service_test.go rename to internal/rpc/services/service_admin_test.go index 4589259f..0d74272d 100644 --- a/internal/rpc/admin/service_test.go +++ b/internal/rpc/services/service_admin_test.go @@ -1,10 +1,11 @@ -package admin +package services import ( "context" "encoding/base64" teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/encrypt" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/pb" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/maps" stringutil "github.com/iwind/TeaGo/utils/string" @@ -13,12 +14,12 @@ import ( "time" ) -func TestService_Login(t *testing.T) { +func TestAdminService_Login(t *testing.T) { a := assert.NewAssertion(t) - service := &Service{ + service := &AdminService{ debug: true, } - resp, err := service.Login(testCtx(t), &LoginRequest{ + resp, err := service.Login(testCtx(t), &pb.AdminLoginRequest{ Username: "admin", Password: stringutil.Md5("123456"), }) @@ -28,10 +29,10 @@ func TestService_Login(t *testing.T) { a.LogJSON(resp) } -func TestService_CreateLog(t *testing.T) { - service := &Service{debug: true} +func TestAdminService_CreateLog(t *testing.T) { + service := &AdminService{debug: true} - resp, err := service.CreateLog(testCtx(t), &CreateLogRequest{ + resp, err := service.CreateLog(testCtx(t), &pb.AdminCreateLogRequest{ Level: "info", Description: "这是一个测试日志", Action: "/login", @@ -43,6 +44,17 @@ func TestService_CreateLog(t *testing.T) { t.Log(resp) } +func TestAdminService_FindAllEnabledClusters(t *testing.T) { + service := &AdminService{ + debug: true, + } + resp, err := service.FindAllEnabledClusters(testCtx(t), &pb.AdminFindAllEnabledClustersRequest{}) + if err != nil { + t.Fatal(err) + } + t.Log(resp) +} + func testCtx(t *testing.T) context.Context { ctx := context.Background() nodeId := "H6sjDf779jimnVPnBFSgZxvr6Ca0wQ0z" diff --git a/internal/rpc/services/service_dns.go b/internal/rpc/services/service_dns.go new file mode 100644 index 00000000..75966836 --- /dev/null +++ b/internal/rpc/services/service_dns.go @@ -0,0 +1,4 @@ +package services + +type DNSService struct { +} diff --git a/internal/rpc/services/service_log.go b/internal/rpc/services/service_log.go new file mode 100644 index 00000000..1c091138 --- /dev/null +++ b/internal/rpc/services/service_log.go @@ -0,0 +1,4 @@ +package services + +type LogService struct { +} diff --git a/internal/rpc/services/service_monitor.go b/internal/rpc/services/service_monitor.go new file mode 100644 index 00000000..cebac939 --- /dev/null +++ b/internal/rpc/services/service_monitor.go @@ -0,0 +1,4 @@ +package services + +type MonitorService struct { +} diff --git a/internal/rpc/services/service_node.go b/internal/rpc/services/service_node.go new file mode 100644 index 00000000..88cf0032 --- /dev/null +++ b/internal/rpc/services/service_node.go @@ -0,0 +1,17 @@ +package services + +import ( + "context" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/pb" + "github.com/iwind/TeaGo/logs" +) + +type NodeService struct { +} + +func (this *NodeService) Config(ctx context.Context, req *pb.ConfigRequest) (*pb.ConfigResponse, error) { + logs.Println("you called me") + return &pb.ConfigResponse{ + Id: req.NodeId, + }, nil +} diff --git a/internal/rpc/services/service_provider.go b/internal/rpc/services/service_provider.go new file mode 100644 index 00000000..f3ef0d9b --- /dev/null +++ b/internal/rpc/services/service_provider.go @@ -0,0 +1,4 @@ +package services + +type ProviderService struct { +} diff --git a/internal/rpc/services/service_stat.go b/internal/rpc/services/service_stat.go new file mode 100644 index 00000000..85e6441f --- /dev/null +++ b/internal/rpc/services/service_stat.go @@ -0,0 +1,4 @@ +package services + +type StatService struct { +} diff --git a/internal/rpc/services/service_user.go b/internal/rpc/services/service_user.go new file mode 100644 index 00000000..b23a2526 --- /dev/null +++ b/internal/rpc/services/service_user.go @@ -0,0 +1,4 @@ +package services + +type UserService struct { +} diff --git a/internal/rpc/stat/service.go b/internal/rpc/stat/service.go deleted file mode 100644 index d292157d..00000000 --- a/internal/rpc/stat/service.go +++ /dev/null @@ -1,4 +0,0 @@ -package stat - -type Service struct { -} diff --git a/internal/rpc/stat/service.proto b/internal/rpc/stat/service.proto deleted file mode 100644 index 9908410d..00000000 --- a/internal/rpc/stat/service.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package stat; - -option go_package = "./stat"; - -service Service { - -} diff --git a/internal/rpc/user/service.go b/internal/rpc/user/service.go deleted file mode 100644 index 5e19ef00..00000000 --- a/internal/rpc/user/service.go +++ /dev/null @@ -1,4 +0,0 @@ -package user - -type Service struct { -} diff --git a/internal/rpc/user/service.proto b/internal/rpc/user/service.proto deleted file mode 100644 index 91ed305e..00000000 --- a/internal/rpc/user/service.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package user; - -option go_package = "./user"; - -service Service { - -} diff --git a/internal/tests/grpc_test.go b/internal/tests/grpc_test.go index 8e41d384..92843e81 100644 --- a/internal/tests/grpc_test.go +++ b/internal/tests/grpc_test.go @@ -3,8 +3,8 @@ package tests import ( "context" "encoding/json" - "github.com/TeaOSLab/EdgeAPI/internal/rpc/admin" - nodepb "github.com/TeaOSLab/EdgeAPI/internal/rpc/node" + pb2 "github.com/TeaOSLab/EdgeAPI/internal/rpc/pb" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" pb "github.com/TeaOSLab/EdgeAPI/internal/tests/helloworld" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -42,8 +42,7 @@ func TestTCPServer(t *testing.T) { s := grpc.NewServer() pb.RegisterGreeterServer(s, &server{}) - nodepb.RegisterServiceServer(s, &nodepb.Service{}) - admin.RegisterServiceServer(s, &admin.Service{}) + pb2.RegisterNodeServiceServer(s, &services.NodeService{}) err = s.Serve(listener) if err != nil { @@ -85,13 +84,13 @@ func TestTCPClient_Node(t *testing.T) { _ = conn.Close() }() - c := nodepb.NewServiceClient(conn) + c := pb2.NewNodeServiceClient(conn) before := time.Now() ctx := context.Background() ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu", "age", "20") - reply, err := c.Config(ctx, &nodepb.ConfigRequest{ + reply, err := c.Config(ctx, &pb2.ConfigRequest{ }) if err != nil { t.Fatal(err) diff --git a/internal/tests/helper_test.go b/internal/tests/helper_test.go index 0d1e0d08..5370f3ca 100644 --- a/internal/tests/helper_test.go +++ b/internal/tests/helper_test.go @@ -2,9 +2,19 @@ package tests import ( "github.com/iwind/TeaGo/rands" + "math" + "net/url" "testing" ) func TestRandString(t *testing.T) { t.Log(rands.HexString(32)) } + +func TestCharset(t *testing.T) { + t.Log(url.QueryEscape("中文")) +} + +func TestInt(t *testing.T) { + t.Log(math.MaxInt64) +} \ No newline at end of file