server.go 598 B

123456789101112131415161718192021222324252627
  1. package grpc
  2. import (
  3. pb "go-common/app/service/live/xroom-feed/api"
  4. "go-common/app/service/live/xroom-feed/internal/service"
  5. "go-common/library/conf/paladin"
  6. "go-common/library/net/rpc/warden"
  7. )
  8. // New new a grpc server.
  9. func New(svc *service.Service) *warden.Server {
  10. var rc struct {
  11. Server *warden.ServerConfig
  12. }
  13. if err := paladin.Get("grpc.toml").UnmarshalTOML(&rc); err != nil {
  14. if err != paladin.ErrNotExist {
  15. panic(err)
  16. }
  17. }
  18. ws := warden.NewServer(rc.Server)
  19. pb.RegisterRecPoolServer(ws.Server(), svc)
  20. ws, err := ws.Start()
  21. if err != nil {
  22. panic(err)
  23. }
  24. return ws
  25. }