server.go 545 B

123456789101112131415161718192021
  1. package grpc
  2. import (
  3. pb "go-common/app/service/live/xcaptcha/api/grpc/v1"
  4. "go-common/app/service/live/xcaptcha/conf"
  5. svc "go-common/app/service/live/xcaptcha/service/v1"
  6. "go-common/library/log"
  7. "go-common/library/net/rpc/warden"
  8. )
  9. // Init gRpc Init
  10. func Init(c *conf.Config) {
  11. s := warden.NewServer(nil) // 酌情传入config
  12. // 每个proto里定义的service添加一行
  13. pb.RegisterXCaptchaServer(s.Server(), svc.NewXCaptchaService(c))
  14. _, err := s.Start()
  15. if err != nil {
  16. log.Error("grpc Start error(%v)", err)
  17. panic(err)
  18. }
  19. }