mult_sync.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/admin/main/videoup/model/archive"
  6. "go-common/library/log"
  7. )
  8. func (s *Service) multSyncProc() {
  9. defer s.wg.Done()
  10. for {
  11. if s.closed {
  12. return
  13. }
  14. var (
  15. c = context.TODO()
  16. err error
  17. sync *archive.MultSyncParam
  18. )
  19. if sync, err = s.busCache.PopMultSync(c); err != nil || sync == nil || sync.Action == "" {
  20. time.Sleep(5 * time.Second)
  21. continue
  22. }
  23. log.Info("sync_action %s %+v", sync.Action, sync)
  24. switch sync.Action {
  25. case archive.ActionVideoSubmit:
  26. if err = s.dealVideo(c, sync.VideoParam); err != nil {
  27. s.busCache.PushMultSync(c, sync)
  28. log.Error("s.dealVideo() error(%v)", err)
  29. continue
  30. }
  31. case archive.ActionArchiveSubmit:
  32. if err = s.dealArchive(c, sync.ArcParam); err != nil {
  33. s.busCache.PushMultSync(c, sync)
  34. log.Error("s.dealArchive() error(%v)", err)
  35. continue
  36. }
  37. case archive.ActionArchiveSecondRound:
  38. if err = s.dealArchiveSecondRound(c, sync.ArcParam); err != nil {
  39. s.busCache.PushMultSync(c, sync)
  40. log.Error("s.dealArchive() error(%v)", err)
  41. continue
  42. }
  43. case archive.ActionArchiveAttr:
  44. if err = s.dealAttrs(c, sync.ArcParam); err != nil {
  45. s.busCache.PushMultSync(c, sync)
  46. log.Error("s.dealAttrs() error(%v)", err)
  47. continue
  48. }
  49. case archive.ActionArchiveTypeID:
  50. if err = s.dealTypeID(c, sync.ArcParam); err != nil {
  51. s.busCache.PushMultSync(c, sync)
  52. log.Error("s.dealTypeID() error(%v)", err)
  53. continue
  54. }
  55. case archive.ActionArchiveTag:
  56. if err = s.dealTag(c, false, sync.ArcParam); err != nil {
  57. s.busCache.PushMultSync(c, sync)
  58. log.Error("s.dealTag() error(%v)", err)
  59. continue
  60. }
  61. case archive.ActionArchiveTagRecheck:
  62. if err = s.dealTag(c, true, sync.ArcParam); err != nil {
  63. s.busCache.PushMultSync(c, sync)
  64. log.Error("s.dealTag() error(%v)", err)
  65. continue
  66. }
  67. default:
  68. log.Info("s.multSyncProc() default action(%s)", sync.Action)
  69. }
  70. }
  71. }