server.go 672 B

1234567891011121314151617181920212223242526272829
  1. package grpc
  2. import (
  3. "fmt"
  4. "go-common/app/service/live/xlottery/dao"
  5. pb "go-common/app/service/live/xlottery/api/grpc/v1"
  6. "go-common/app/service/live/xlottery/conf"
  7. svc "go-common/app/service/live/xlottery/service/v1"
  8. "go-common/library/log"
  9. "go-common/library/net/rpc/warden"
  10. )
  11. // Init .
  12. func Init(c *conf.Config) *warden.Server {
  13. dao.InitAPI()
  14. s := warden.NewServer(nil) // 酌情传入config
  15. gs := svc.NewCapsuleService(c)
  16. pb.RegisterCapsuleServer(s.Server(), gs)
  17. pb.RegisterStormServer(s.Server(), svc.NewStromService(c))
  18. _, err := s.Start()
  19. if err != nil {
  20. log.Error("grpc Start error(%v)", err)
  21. panic(err)
  22. }
  23. fmt.Println("start")
  24. return s
  25. }