service_test.go 976 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package service
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "sync"
  6. "time"
  7. "go-common/app/job/openplatform/article/conf"
  8. "go-common/app/job/openplatform/article/dao"
  9. "go-common/library/queue/databus"
  10. )
  11. // func WithService(f func(s *Service)) func() {
  12. // return func() {
  13. // dir, _ := filepath.Abs("../goconvey.toml")
  14. // flag.Set("conf", dir)
  15. // conf.Init()
  16. // s := New(conf.Conf)
  17. // // s.dao = dao.New(conf.Conf)
  18. // f(s)
  19. // }
  20. // }
  21. func WithoutProcService(f func(s *Service)) func() {
  22. return func() {
  23. dir, _ := filepath.Abs("../goconvey.toml")
  24. flag.Set("conf", dir)
  25. conf.Init()
  26. s := &Service{
  27. c: conf.Conf,
  28. dao: dao.New(conf.Conf),
  29. waiter: new(sync.WaitGroup),
  30. // articleRPC: artrpc.New(conf.Conf.ArticleRPC),
  31. articleSub: databus.New(conf.Conf.ArticleSub),
  32. articleStatSub: databus.New(conf.Conf.ArticleStatSub),
  33. updateDbInterval: int64(time.Duration(conf.Conf.Job.UpdateDbInterval) / time.Second),
  34. }
  35. f(s)
  36. }
  37. }