base.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package base
  2. import (
  3. "go-common/app/job/main/search/conf"
  4. "go-common/app/job/main/search/dao"
  5. bsn "go-common/app/job/main/search/dao/business"
  6. )
  7. // Base .
  8. type Base struct {
  9. D *dao.Dao
  10. C *conf.Config
  11. }
  12. // NewBase .
  13. func NewBase(c *conf.Config) (b *Base) {
  14. b = &Base{
  15. C: c,
  16. D: dao.New(c),
  17. }
  18. b.D.AppPool = b.newAppPool(b.D)
  19. return
  20. }
  21. // newAppPool .
  22. func (b *Base) newAppPool(d *dao.Dao) (pool map[string]dao.App) {
  23. pool = make(map[string]dao.App)
  24. for k, v := range d.BusinessPool {
  25. switch v.IncrWay {
  26. case "single":
  27. pool[k] = dao.NewAppSingle(d, k)
  28. case "multiple":
  29. pool[k] = dao.NewAppMultiple(d, k)
  30. case "dtb":
  31. pool[k] = dao.NewAppDatabus(d, k)
  32. case "multipleDtb":
  33. pool[k] = dao.NewAppMultipleDatabus(d, k)
  34. case "business":
  35. switch k {
  36. case "archive_video":
  37. pool[k] = bsn.NewAvr(d, k, b.C)
  38. case "avr_archive", "avr_video":
  39. pool[k] = bsn.NewAvrArchive(d, k)
  40. case "log_audit", "log_user_action":
  41. pool[k] = bsn.NewLog(d, k)
  42. case "dm_date":
  43. pool[k] = bsn.NewDmDate(d, k)
  44. case "aegis_resource":
  45. pool[k] = bsn.NewAegisResource(d, k, b.C)
  46. }
  47. default:
  48. // to do other thing
  49. }
  50. }
  51. //fmt.Println("strace:app-pool>", pool)
  52. return
  53. }