transform.go 882 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Code generated by goctl. DO NOT EDIT!
  2. // Source: transform.proto
  3. package main
  4. import (
  5. "flag"
  6. "fmt"
  7. "log"
  8. "shorturl/rpc/transform/internal/config"
  9. "shorturl/rpc/transform/internal/server"
  10. "shorturl/rpc/transform/internal/svc"
  11. transform "shorturl/rpc/transform/pb"
  12. "github.com/tal-tech/go-zero/core/conf"
  13. "github.com/tal-tech/go-zero/zrpc"
  14. "google.golang.org/grpc"
  15. )
  16. var configFile = flag.String("f", "etc/transform.yaml", "the config file")
  17. func main() {
  18. flag.Parse()
  19. var c config.Config
  20. conf.MustLoad(*configFile, &c)
  21. ctx := svc.NewServiceContext(c)
  22. transformerSrv := server.NewTransformerServer(ctx)
  23. s, err := zrpc.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
  24. transform.RegisterTransformerServer(grpcServer, transformerSrv)
  25. })
  26. if err != nil {
  27. log.Fatal(err)
  28. }
  29. fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
  30. s.Start()
  31. }