service.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package view
  2. import (
  3. "context"
  4. "go-common/app/interface/main/tv/conf"
  5. "go-common/app/interface/main/tv/dao/account"
  6. "go-common/app/interface/main/tv/dao/archive"
  7. "go-common/app/interface/main/tv/dao/cms"
  8. "go-common/app/interface/main/tv/dao/favorite"
  9. "go-common/app/interface/main/tv/dao/upper"
  10. "go-common/library/stat/prom"
  11. )
  12. // Service .
  13. type Service struct {
  14. conf *conf.Config
  15. // dao
  16. arcDao *archive.Dao
  17. accDao *account.Dao
  18. cmsDao *cms.Dao
  19. upDao *upper.Dao
  20. favDao *favorite.Dao
  21. // prom
  22. pHit *prom.Prom
  23. pMiss *prom.Prom
  24. prom *prom.Prom
  25. emptyArcCh chan int64
  26. }
  27. var ctx = context.TODO()
  28. // New .
  29. func New(c *conf.Config) *Service {
  30. srv := &Service{
  31. conf: c,
  32. arcDao: archive.New(c),
  33. accDao: account.New(c),
  34. cmsDao: cms.New(c),
  35. upDao: upper.New(c),
  36. favDao: favorite.New(c),
  37. pHit: prom.CacheHit,
  38. pMiss: prom.CacheMiss,
  39. prom: prom.BusinessInfoCount,
  40. emptyArcCh: make(chan int64, c.Cfg.EmptyArc.ChanSize),
  41. }
  42. go srv.emptyArcproc()
  43. return srv
  44. }