2024-10-25 10:17:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2024-10-25 16:42:58 +00:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
2024-10-25 10:17:27 +00:00
|
|
|
|
|
|
|
"app-cloudep-trade-service/gen_result/pb/trade"
|
|
|
|
"app-cloudep-trade-service/internal/config"
|
|
|
|
couponserviceServer "app-cloudep-trade-service/internal/server/couponservice"
|
|
|
|
inventoryserviceServer "app-cloudep-trade-service/internal/server/inventoryservice"
|
|
|
|
orderserviceServer "app-cloudep-trade-service/internal/server/orderservice"
|
|
|
|
productserviceServer "app-cloudep-trade-service/internal/server/productservice"
|
|
|
|
subscriptionserviceServer "app-cloudep-trade-service/internal/server/subscriptionservice"
|
|
|
|
walletserviceServer "app-cloudep-trade-service/internal/server/walletservice"
|
|
|
|
"app-cloudep-trade-service/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/trade.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) {
|
|
|
|
trade.RegisterOrderServiceServer(grpcServer, orderserviceServer.NewOrderServiceServer(ctx))
|
|
|
|
trade.RegisterWalletServiceServer(grpcServer, walletserviceServer.NewWalletServiceServer(ctx))
|
|
|
|
trade.RegisterInventoryServiceServer(grpcServer, inventoryserviceServer.NewInventoryServiceServer(ctx))
|
|
|
|
trade.RegisterProductServiceServer(grpcServer, productserviceServer.NewProductServiceServer(ctx))
|
|
|
|
trade.RegisterSubscriptionServiceServer(grpcServer, subscriptionserviceServer.NewSubscriptionServiceServer(ctx))
|
|
|
|
trade.RegisterCouponServiceServer(grpcServer, couponserviceServer.NewCouponServiceServer(ctx))
|
|
|
|
|
|
|
|
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
|
|
|
reflection.Register(grpcServer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
defer s.Stop()
|
|
|
|
|
2024-10-25 16:42:58 +00:00
|
|
|
logx.Infof("Starting rpc server at %s...\n", c.ListenOn)
|
2024-10-25 10:17:27 +00:00
|
|
|
s.Start()
|
|
|
|
}
|