ark-member/member.go

44 lines
976 B
Go
Raw Normal View History

2024-07-21 15:57:56 +00:00
package main
import (
"flag"
"fmt"
"member/internal/lib/middleware"
"member/gen_result/pb/member"
"member/internal/config"
"member/internal/server"
"member/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/member.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) {
member.RegisterAccountServer(grpcServer, server.NewAccountServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
2024-08-02 02:10:25 +00:00
// 加入中間件
2024-07-21 15:57:56 +00:00
s.AddUnaryInterceptors(middleware.TimeoutMiddleware)
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}