app-cloudep-tweeting-service/tweeting.go

46 lines
1.6 KiB
Go
Raw Normal View History

2024-08-28 09:09:01 +00:00
package main
import (
"flag"
"fmt"
2024-08-28 14:29:42 +00:00
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
"app-cloudep-tweeting-service/internal/config"
2024-09-03 01:17:50 +00:00
commentserviceServer "app-cloudep-tweeting-service/internal/server/commentservice"
2024-08-28 14:29:42 +00:00
postserviceServer "app-cloudep-tweeting-service/internal/server/postservice"
2024-09-03 01:17:50 +00:00
socialnetworkserviceServer "app-cloudep-tweeting-service/internal/server/socialnetworkservice"
timelineserviceServer "app-cloudep-tweeting-service/internal/server/timelineservice"
2024-08-28 14:29:42 +00:00
"app-cloudep-tweeting-service/internal/svc"
2024-08-28 09:09:01 +00:00
"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"
)
2024-08-28 14:24:47 +00:00
var configFile = flag.String("f", "etc/tweeting.yaml", "the config file")
2024-08-28 09:09:01 +00:00
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-28 14:24:47 +00:00
tweeting.RegisterPostServiceServer(grpcServer, postserviceServer.NewPostServiceServer(ctx))
2024-09-03 01:17:50 +00:00
tweeting.RegisterCommentServiceServer(grpcServer, commentserviceServer.NewCommentServiceServer(ctx))
tweeting.RegisterTimelineServiceServer(grpcServer, timelineserviceServer.NewTimelineServiceServer(ctx))
tweeting.RegisterSocialNetworkServiceServer(grpcServer, socialnetworkserviceServer.NewSocialNetworkServiceServer(ctx))
2024-08-28 09:09:01 +00:00
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()
}