service.go 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package service
  2. import (
  3. "go-common/app/interface/live/lottery-interface/internal/conf"
  4. risk "go-common/app/service/live/live_riskcontrol/api/grpc/v1"
  5. storm "go-common/app/service/live/xlottery/api/grpc/v1"
  6. "go-common/library/log/infoc"
  7. )
  8. // Service struct
  9. type Service struct {
  10. c *conf.Config
  11. Infoc *infoc.Infoc
  12. StormClient storm.StormClient
  13. IsForbiddenClient risk.IsForbiddenClient
  14. }
  15. // New init
  16. func New(c *conf.Config) (s *Service) {
  17. sc, err := storm.NewClient(c.LongClient)
  18. if err != nil {
  19. panic(err)
  20. }
  21. isForbiddenClient, err := risk.NewClient(c.ShortClient)
  22. if err != nil {
  23. panic(err)
  24. }
  25. s = &Service{
  26. c: c,
  27. Infoc: infoc.New(c.Infoc),
  28. StormClient: sc.StormClient,
  29. IsForbiddenClient: isForbiddenClient,
  30. }
  31. return s
  32. }
  33. // Close Service
  34. func (s *Service) Close() {
  35. s.Infoc.Close()
  36. }
  37. // ServiceInstance instance
  38. var ServiceInstance *Service
  39. // Init init
  40. func Init(c *conf.Config) {
  41. ServiceInstance = New(c)
  42. }