transfer.go 929 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "ylink/core/transfer/rpc/internal/config"
  6. "ylink/core/transfer/rpc/internal/server"
  7. "ylink/core/transfer/rpc/internal/svc"
  8. "ylink/core/transfer/rpc/pb"
  9. "github.com/zeromicro/go-zero/core/conf"
  10. "github.com/zeromicro/go-zero/core/service"
  11. "github.com/zeromicro/go-zero/zrpc"
  12. "google.golang.org/grpc"
  13. "google.golang.org/grpc/reflection"
  14. )
  15. var configFile = flag.String("f", "etc/transfer.yaml", "the config file")
  16. func main() {
  17. flag.Parse()
  18. var c config.Config
  19. conf.MustLoad(*configFile, &c)
  20. ctx := svc.NewServiceContext(c)
  21. svr := server.NewTransferServer(ctx)
  22. s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
  23. pb.RegisterTransferServer(grpcServer, svr)
  24. if c.Mode == service.DevMode || c.Mode == service.TestMode {
  25. reflection.Register(grpcServer)
  26. }
  27. })
  28. defer s.Stop()
  29. fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
  30. s.Start()
  31. }