2025-03-12 14:05:38 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2025-04-09 14:46:53 +00:00
|
|
|
"fmt"
|
2025-03-12 14:05:38 +00:00
|
|
|
|
|
|
|
"code.30cm.net/digimon/app-cloudep-product-service/gen_result/pb/product"
|
|
|
|
"code.30cm.net/digimon/app-cloudep-product-service/internal/config"
|
2025-04-09 14:46:53 +00:00
|
|
|
category_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/category_service"
|
|
|
|
kyc_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/kyc_service"
|
|
|
|
product_item_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/product_item_service"
|
|
|
|
tag_serviceServer "code.30cm.net/digimon/app-cloudep-product-service/internal/server/tag_service"
|
2025-03-12 14:05:38 +00:00
|
|
|
"code.30cm.net/digimon/app-cloudep-product-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/product.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) {
|
2025-04-09 14:46:53 +00:00
|
|
|
product.RegisterCategory_ServiceServer(grpcServer, category_serviceServer.NewCategoryServiceServer(ctx))
|
|
|
|
product.RegisterTag_ServiceServer(grpcServer, tag_serviceServer.NewTagServiceServer(ctx))
|
|
|
|
product.RegisterKyc_ServiceServer(grpcServer, kyc_serviceServer.NewKycServiceServer(ctx))
|
|
|
|
product.RegisterProduct_Item_ServiceServer(grpcServer, product_item_serviceServer.NewProductItemServiceServer(ctx))
|
2025-03-12 14:05:38 +00:00
|
|
|
|
|
|
|
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
|
|
|
reflection.Register(grpcServer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
defer s.Stop()
|
|
|
|
|
2025-04-09 14:46:53 +00:00
|
|
|
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
|
2025-03-12 14:05:38 +00:00
|
|
|
s.Start()
|
|
|
|
}
|