2024-08-05 09:11:43 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-08-10 01:52:23 +00:00
|
|
|
permissionservice "ark-permission/internal/server/permissionservice"
|
|
|
|
roleservice "ark-permission/internal/server/roleservice"
|
|
|
|
tokenservice "ark-permission/internal/server/tokenservice"
|
2024-08-05 09:11:43 +00:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"ark-permission/gen_result/pb/permission"
|
|
|
|
"ark-permission/internal/config"
|
|
|
|
"ark-permission/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/permission.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) {
|
2024-08-10 01:52:23 +00:00
|
|
|
permission.RegisterTokenServiceServer(grpcServer, tokenservice.NewTokenServiceServer(ctx))
|
|
|
|
permission.RegisterRoleServiceServer(grpcServer, roleservice.NewRoleServiceServer(ctx))
|
|
|
|
permission.RegisterPermissionServiceServer(grpcServer, permissionservice.NewPermissionServiceServer(ctx))
|
2024-08-05 09:11:43 +00:00
|
|
|
|
|
|
|
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
|
|
|
reflection.Register(grpcServer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
defer s.Stop()
|
|
|
|
|
2024-08-08 03:02:13 +00:00
|
|
|
// 加入中間件
|
2024-08-06 05:59:24 +00:00
|
|
|
// s.AddUnaryInterceptors(middleware.TimeoutMiddleware)
|
|
|
|
|
2024-08-05 09:11:43 +00:00
|
|
|
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
|
|
|
|
s.Start()
|
|
|
|
}
|