初始化
Build docker and publish / prepare (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.admin image_name:ppanel-admin name:admin]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.api image_name:ppanel-api name:api]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.node image_name:ppanel-node name:node]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.queue image_name:ppanel-queue name:queue]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.scheduler image_name:ppanel-scheduler name:scheduler]) (push) Has been cancelled
Build docker and publish / deploy (push) Has been cancelled
Build docker and publish / notify (push) Has been cancelled

This commit is contained in:
2026-02-26 04:12:43 -08:00
commit 9dacd85a89
210 changed files with 8261 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
package main
import (
"flag"
"fmt"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/core"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/config"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/server"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/svc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/core.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
core.RegisterCoreServer(grpcServer, server.NewCoreServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}
+56
View File
@@ -0,0 +1,56 @@
syntax = "proto3";
package core;
option go_package = "./core";
// ----------------------------------------------------------------------------
// 通用结构
// ----------------------------------------------------------------------------
message Empty {}
message BasicResponse {
int32 code = 1;
string msg = 2;
}
// ----------------------------------------------------------------------------
// User 服务定义
// ----------------------------------------------------------------------------
message GetUserInfoReq {
int64 id = 1;
}
message GetUserInfoResp {
int64 id = 1;
string email = 2;
string role = 3;
string uuid = 4;
}
// ----------------------------------------------------------------------------
// Node 服务定义
// ----------------------------------------------------------------------------
message GetNodeInfoReq {
int64 id = 1;
}
message GetNodeInfoResp {
int64 id = 1;
string name = 2;
string server = 3;
string status = 4;
}
// ----------------------------------------------------------------------------
// 核心 RPC 服务接口
// ----------------------------------------------------------------------------
service Core {
// Ping 检查服务健康状态
rpc Ping(Empty) returns(BasicResponse);
// 用户相关
rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
// 节点相关
rpc GetNodeInfo(GetNodeInfoReq) returns(GetNodeInfoResp);
}
+431
View File
@@ -0,0 +1,431 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc v6.33.4
// source: core.proto
package core
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
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)
)
// ----------------------------------------------------------------------------
// 通用结构
// ----------------------------------------------------------------------------
type Empty struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Empty) Reset() {
*x = Empty{}
mi := &file_core_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Empty) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Empty) ProtoMessage() {}
func (x *Empty) ProtoReflect() protoreflect.Message {
mi := &file_core_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
func (*Empty) Descriptor() ([]byte, []int) {
return file_core_proto_rawDescGZIP(), []int{0}
}
type BasicResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *BasicResponse) Reset() {
*x = BasicResponse{}
mi := &file_core_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BasicResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BasicResponse) ProtoMessage() {}
func (x *BasicResponse) ProtoReflect() protoreflect.Message {
mi := &file_core_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BasicResponse.ProtoReflect.Descriptor instead.
func (*BasicResponse) Descriptor() ([]byte, []int) {
return file_core_proto_rawDescGZIP(), []int{1}
}
func (x *BasicResponse) GetCode() int32 {
if x != nil {
return x.Code
}
return 0
}
func (x *BasicResponse) GetMsg() string {
if x != nil {
return x.Msg
}
return ""
}
// ----------------------------------------------------------------------------
// User 服务定义
// ----------------------------------------------------------------------------
type GetUserInfoReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserInfoReq) Reset() {
*x = GetUserInfoReq{}
mi := &file_core_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserInfoReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserInfoReq) ProtoMessage() {}
func (x *GetUserInfoReq) ProtoReflect() protoreflect.Message {
mi := &file_core_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserInfoReq.ProtoReflect.Descriptor instead.
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
return file_core_proto_rawDescGZIP(), []int{2}
}
func (x *GetUserInfoReq) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
type GetUserInfoResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
Role string `protobuf:"bytes,3,opt,name=role,proto3" json:"role,omitempty"`
Uuid string `protobuf:"bytes,4,opt,name=uuid,proto3" json:"uuid,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserInfoResp) Reset() {
*x = GetUserInfoResp{}
mi := &file_core_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserInfoResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserInfoResp) ProtoMessage() {}
func (x *GetUserInfoResp) ProtoReflect() protoreflect.Message {
mi := &file_core_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserInfoResp.ProtoReflect.Descriptor instead.
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
return file_core_proto_rawDescGZIP(), []int{3}
}
func (x *GetUserInfoResp) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *GetUserInfoResp) GetEmail() string {
if x != nil {
return x.Email
}
return ""
}
func (x *GetUserInfoResp) GetRole() string {
if x != nil {
return x.Role
}
return ""
}
func (x *GetUserInfoResp) GetUuid() string {
if x != nil {
return x.Uuid
}
return ""
}
// ----------------------------------------------------------------------------
// Node 服务定义
// ----------------------------------------------------------------------------
type GetNodeInfoReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetNodeInfoReq) Reset() {
*x = GetNodeInfoReq{}
mi := &file_core_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetNodeInfoReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetNodeInfoReq) ProtoMessage() {}
func (x *GetNodeInfoReq) ProtoReflect() protoreflect.Message {
mi := &file_core_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetNodeInfoReq.ProtoReflect.Descriptor instead.
func (*GetNodeInfoReq) Descriptor() ([]byte, []int) {
return file_core_proto_rawDescGZIP(), []int{4}
}
func (x *GetNodeInfoReq) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
type GetNodeInfoResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Server string `protobuf:"bytes,3,opt,name=server,proto3" json:"server,omitempty"`
Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetNodeInfoResp) Reset() {
*x = GetNodeInfoResp{}
mi := &file_core_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetNodeInfoResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetNodeInfoResp) ProtoMessage() {}
func (x *GetNodeInfoResp) ProtoReflect() protoreflect.Message {
mi := &file_core_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetNodeInfoResp.ProtoReflect.Descriptor instead.
func (*GetNodeInfoResp) Descriptor() ([]byte, []int) {
return file_core_proto_rawDescGZIP(), []int{5}
}
func (x *GetNodeInfoResp) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *GetNodeInfoResp) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *GetNodeInfoResp) GetServer() string {
if x != nil {
return x.Server
}
return ""
}
func (x *GetNodeInfoResp) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
var File_core_proto protoreflect.FileDescriptor
const file_core_proto_rawDesc = "" +
"\n" +
"\n" +
"core.proto\x12\x04core\"\a\n" +
"\x05Empty\"5\n" +
"\rBasicResponse\x12\x12\n" +
"\x04code\x18\x01 \x01(\x05R\x04code\x12\x10\n" +
"\x03msg\x18\x02 \x01(\tR\x03msg\" \n" +
"\x0eGetUserInfoReq\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\"_\n" +
"\x0fGetUserInfoResp\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
"\x05email\x18\x02 \x01(\tR\x05email\x12\x12\n" +
"\x04role\x18\x03 \x01(\tR\x04role\x12\x12\n" +
"\x04uuid\x18\x04 \x01(\tR\x04uuid\" \n" +
"\x0eGetNodeInfoReq\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\"e\n" +
"\x0fGetNodeInfoResp\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x16\n" +
"\x06server\x18\x03 \x01(\tR\x06server\x12\x16\n" +
"\x06status\x18\x04 \x01(\tR\x06status2\xa8\x01\n" +
"\x04Core\x12(\n" +
"\x04Ping\x12\v.core.Empty\x1a\x13.core.BasicResponse\x12:\n" +
"\vGetUserInfo\x12\x14.core.GetUserInfoReq\x1a\x15.core.GetUserInfoResp\x12:\n" +
"\vGetNodeInfo\x12\x14.core.GetNodeInfoReq\x1a\x15.core.GetNodeInfoRespB\bZ\x06./coreb\x06proto3"
var (
file_core_proto_rawDescOnce sync.Once
file_core_proto_rawDescData []byte
)
func file_core_proto_rawDescGZIP() []byte {
file_core_proto_rawDescOnce.Do(func() {
file_core_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_core_proto_rawDesc), len(file_core_proto_rawDesc)))
})
return file_core_proto_rawDescData
}
var file_core_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_core_proto_goTypes = []any{
(*Empty)(nil), // 0: core.Empty
(*BasicResponse)(nil), // 1: core.BasicResponse
(*GetUserInfoReq)(nil), // 2: core.GetUserInfoReq
(*GetUserInfoResp)(nil), // 3: core.GetUserInfoResp
(*GetNodeInfoReq)(nil), // 4: core.GetNodeInfoReq
(*GetNodeInfoResp)(nil), // 5: core.GetNodeInfoResp
}
var file_core_proto_depIdxs = []int32{
0, // 0: core.Core.Ping:input_type -> core.Empty
2, // 1: core.Core.GetUserInfo:input_type -> core.GetUserInfoReq
4, // 2: core.Core.GetNodeInfo:input_type -> core.GetNodeInfoReq
1, // 3: core.Core.Ping:output_type -> core.BasicResponse
3, // 4: core.Core.GetUserInfo:output_type -> core.GetUserInfoResp
5, // 5: core.Core.GetNodeInfo:output_type -> core.GetNodeInfoResp
3, // [3:6] is the sub-list for method output_type
0, // [0:3] 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_core_proto_init() }
func file_core_proto_init() {
if File_core_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_core_proto_rawDesc), len(file_core_proto_rawDesc)),
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_core_proto_goTypes,
DependencyIndexes: file_core_proto_depIdxs,
MessageInfos: file_core_proto_msgTypes,
}.Build()
File_core_proto = out.File
file_core_proto_goTypes = nil
file_core_proto_depIdxs = nil
}
+211
View File
@@ -0,0 +1,211 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc v6.33.4
// source: core.proto
package core
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Core_Ping_FullMethodName = "/core.Core/Ping"
Core_GetUserInfo_FullMethodName = "/core.Core/GetUserInfo"
Core_GetNodeInfo_FullMethodName = "/core.Core/GetNodeInfo"
)
// CoreClient is the client API for Core service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// ----------------------------------------------------------------------------
// 核心 RPC 服务接口
// ----------------------------------------------------------------------------
type CoreClient interface {
// Ping 检查服务健康状态
Ping(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BasicResponse, error)
// 用户相关
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
// 节点相关
GetNodeInfo(ctx context.Context, in *GetNodeInfoReq, opts ...grpc.CallOption) (*GetNodeInfoResp, error)
}
type coreClient struct {
cc grpc.ClientConnInterface
}
func NewCoreClient(cc grpc.ClientConnInterface) CoreClient {
return &coreClient{cc}
}
func (c *coreClient) Ping(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BasicResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(BasicResponse)
err := c.cc.Invoke(ctx, Core_Ping_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *coreClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserInfoResp)
err := c.cc.Invoke(ctx, Core_GetUserInfo_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *coreClient) GetNodeInfo(ctx context.Context, in *GetNodeInfoReq, opts ...grpc.CallOption) (*GetNodeInfoResp, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetNodeInfoResp)
err := c.cc.Invoke(ctx, Core_GetNodeInfo_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// CoreServer is the server API for Core service.
// All implementations must embed UnimplementedCoreServer
// for forward compatibility.
//
// ----------------------------------------------------------------------------
// 核心 RPC 服务接口
// ----------------------------------------------------------------------------
type CoreServer interface {
// Ping 检查服务健康状态
Ping(context.Context, *Empty) (*BasicResponse, error)
// 用户相关
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
// 节点相关
GetNodeInfo(context.Context, *GetNodeInfoReq) (*GetNodeInfoResp, error)
mustEmbedUnimplementedCoreServer()
}
// UnimplementedCoreServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedCoreServer struct{}
func (UnimplementedCoreServer) Ping(context.Context, *Empty) (*BasicResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Ping not implemented")
}
func (UnimplementedCoreServer) GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetUserInfo not implemented")
}
func (UnimplementedCoreServer) GetNodeInfo(context.Context, *GetNodeInfoReq) (*GetNodeInfoResp, error) {
return nil, status.Error(codes.Unimplemented, "method GetNodeInfo not implemented")
}
func (UnimplementedCoreServer) mustEmbedUnimplementedCoreServer() {}
func (UnimplementedCoreServer) testEmbeddedByValue() {}
// UnsafeCoreServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CoreServer will
// result in compilation errors.
type UnsafeCoreServer interface {
mustEmbedUnimplementedCoreServer()
}
func RegisterCoreServer(s grpc.ServiceRegistrar, srv CoreServer) {
// If the following call panics, it indicates UnimplementedCoreServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Core_ServiceDesc, srv)
}
func _Core_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CoreServer).Ping(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Core_Ping_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CoreServer).Ping(ctx, req.(*Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Core_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CoreServer).GetUserInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Core_GetUserInfo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CoreServer).GetUserInfo(ctx, req.(*GetUserInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _Core_GetNodeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetNodeInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CoreServer).GetNodeInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Core_GetNodeInfo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CoreServer).GetNodeInfo(ctx, req.(*GetNodeInfoReq))
}
return interceptor(ctx, in, info, handler)
}
// Core_ServiceDesc is the grpc.ServiceDesc for Core service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Core_ServiceDesc = grpc.ServiceDesc{
ServiceName: "core.Core",
HandlerType: (*CoreServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Ping",
Handler: _Core_Ping_Handler,
},
{
MethodName: "GetUserInfo",
Handler: _Core_GetUserInfo_Handler,
},
{
MethodName: "GetNodeInfo",
Handler: _Core_GetNodeInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "core.proto",
}
+60
View File
@@ -0,0 +1,60 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.2
// Source: core.proto
package coreClient
import (
"context"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/core"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
BasicResponse = core.BasicResponse
Empty = core.Empty
GetNodeInfoReq = core.GetNodeInfoReq
GetNodeInfoResp = core.GetNodeInfoResp
GetUserInfoReq = core.GetUserInfoReq
GetUserInfoResp = core.GetUserInfoResp
Core interface {
// Ping 检查服务健康状态
Ping(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BasicResponse, error)
// 用户相关
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
// 节点相关
GetNodeInfo(ctx context.Context, in *GetNodeInfoReq, opts ...grpc.CallOption) (*GetNodeInfoResp, error)
}
defaultCore struct {
cli zrpc.Client
}
)
func NewCore(cli zrpc.Client) Core {
return &defaultCore{
cli: cli,
}
}
// Ping 检查服务健康状态
func (m *defaultCore) Ping(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*BasicResponse, error) {
client := core.NewCoreClient(m.cli.Conn())
return client.Ping(ctx, in, opts...)
}
// 用户相关
func (m *defaultCore) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
client := core.NewCoreClient(m.cli.Conn())
return client.GetUserInfo(ctx, in, opts...)
}
// 节点相关
func (m *defaultCore) GetNodeInfo(ctx context.Context, in *GetNodeInfoReq, opts ...grpc.CallOption) (*GetNodeInfoResp, error) {
client := core.NewCoreClient(m.cli.Conn())
return client.GetNodeInfo(ctx, in, opts...)
}
+30
View File
@@ -0,0 +1,30 @@
Name: core.rpc
ListenOn: 0.0.0.0:8083
Mode: dev
Log:
Mode: console
Encoding: plain
Level: debug
Telemetry:
Name: core.rpc
Endpoint: 127.0.0.1:4318
Sampler: 1.0
Batcher: otlphttp
DevServer:
Enabled: true
Port: 6163
EnableMetrics: true
EnablePprof: true
MySQL:
DataSource: "root:password@tcp(127.0.0.1:3306)/ppanel?charset=utf8mb4&parseTime=true"
CacheRedis:
Host: 127.0.0.1:6379
Type: node
# 注意:RPC 服务我们推荐直连注册中心 Etcd(生产环境),但本地开发为了省事可以使用直连(Direct)
# 目前暂不配置 Etcd,由调用方通过 target: "127.0.0.1:8083" 直连
+30
View File
@@ -0,0 +1,30 @@
Name: core.rpc
ListenOn: 0.0.0.0:8083
Mode: dev
Log:
Mode: console
Encoding: plain
Level: debug
Telemetry:
Name: core.rpc
Endpoint: 127.0.0.1:4318
Sampler: 1.0
Batcher: otlphttp
DevServer:
Enabled: true
Port: 6163
EnableMetrics: true
EnablePprof: true
MySQL:
DataSource: "root:password@tcp(127.0.0.1:3306)/ppanel?charset=utf8mb4&parseTime=true"
CacheRedis:
Host: 127.0.0.1:6379
Type: node
# 注意:RPC 服务我们推荐直连注册中心 Etcd(生产环境),但本地开发为了省事可以使用直连(Direct)
# 目前暂不配置 Etcd,由调用方通过 target: "127.0.0.1:8083" 直连
+30
View File
@@ -0,0 +1,30 @@
Name: core.rpc
ListenOn: 0.0.0.0:8083
Mode: dev
Log:
Mode: console
Encoding: plain
Level: debug
Telemetry:
Name: core.rpc
Endpoint: 127.0.0.1:4318
Sampler: 1.0
Batcher: otlphttp
DevServer:
Enabled: true
Port: 6163
EnableMetrics: true
EnablePprof: true
MySQL:
DataSource: "root:password@tcp(127.0.0.1:3306)/ppanel?charset=utf8mb4&parseTime=true"
CacheRedis:
Host: 127.0.0.1:6379
Type: node
# 注意:RPC 服务我们推荐直连注册中心 Etcd(生产环境),但本地开发为了省事可以使用直连(Direct)
# 目前暂不配置 Etcd,由调用方通过 target: "127.0.0.1:8083" 直连
+15
View File
@@ -0,0 +1,15 @@
package config
import (
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
zrpc.RpcServerConf
MySQL struct {
DataSource string
}
CacheRedis redis.RedisConf
}
@@ -0,0 +1,31 @@
package logic
import (
"context"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/core"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetNodeInfoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetNodeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNodeInfoLogic {
return &GetNodeInfoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 节点相关
func (l *GetNodeInfoLogic) GetNodeInfo(in *core.GetNodeInfoReq) (*core.GetNodeInfoResp, error) {
// todo: add your logic here and delete this line
return &core.GetNodeInfoResp{}, nil
}
@@ -0,0 +1,31 @@
package logic
import (
"context"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/core"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetUserInfoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
return &GetUserInfoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 用户相关
func (l *GetUserInfoLogic) GetUserInfo(in *core.GetUserInfoReq) (*core.GetUserInfoResp, error) {
// todo: add your logic here and delete this line
return &core.GetUserInfoResp{}, nil
}
+35
View File
@@ -0,0 +1,35 @@
package logic
import (
"context"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/core"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type PingLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
return &PingLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// Ping 检查服务健康状态
func (l *PingLogic) Ping(in *core.Empty) (*core.BasicResponse, error) {
// 记录一行日志,这样我们能在 Jaeger 和控制台看到追踪信息
l.Logger.Info("Received Ping request from BFF")
return &core.BasicResponse{
Code: 200,
Msg: "pong from core-rpc",
}, nil
}
@@ -0,0 +1,42 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.2
// Source: core.proto
package server
import (
"context"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/core"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/logic"
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/svc"
)
type CoreServer struct {
svcCtx *svc.ServiceContext
core.UnimplementedCoreServer
}
func NewCoreServer(svcCtx *svc.ServiceContext) *CoreServer {
return &CoreServer{
svcCtx: svcCtx,
}
}
// Ping 检查服务健康状态
func (s *CoreServer) Ping(ctx context.Context, in *core.Empty) (*core.BasicResponse, error) {
l := logic.NewPingLogic(ctx, s.svcCtx)
return l.Ping(in)
}
// 用户相关
func (s *CoreServer) GetUserInfo(ctx context.Context, in *core.GetUserInfoReq) (*core.GetUserInfoResp, error) {
l := logic.NewGetUserInfoLogic(ctx, s.svcCtx)
return l.GetUserInfo(in)
}
// 节点相关
func (s *CoreServer) GetNodeInfo(ctx context.Context, in *core.GetNodeInfoReq) (*core.GetNodeInfoResp, error) {
l := logic.NewGetNodeInfoLogic(ctx, s.svcCtx)
return l.GetNodeInfo(in)
}
@@ -0,0 +1,13 @@
package svc
import "github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/config"
type ServiceContext struct {
Config config.Config
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
}
}