task_mapper.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. class Const:
  2. # task status
  3. TASK_INIT_STATUS = 0
  4. TASK_PROCESSING_STATUS = 1
  5. TASK_SUCCESS_STATUS = 2
  6. TASK_FAILED_STATUS = 99
  7. # DEFAULT
  8. DEFAULT_TIMEOUT = 1800
  9. # duration
  10. CHECK_KIMI_BALANCE_TIMEOUT = 20
  11. GET_OFF_VIDEO_TIMEOUT = 1800
  12. CHECK_VIDEO_AUDIT_TIMEOUT = 1800
  13. OUTSIDE_ARTICLE_MONITOR_TIMEOUT = 3 * 3600
  14. INNER_ARTICLE_MONITOR_TIMEOUT = 3600
  15. TITLE_REWRITE_TIMEOUT = 1800
  16. RECYCLE_DAILY_ARTICLE_TIMEOUT = 3600
  17. UPDATE_ROOT_SOURCE_ID_TIMEOUT = 3600
  18. CRAWLER_TOUTIAO_ARTICLES_TIMEOUT = 5 * 3600
  19. class TaskMapper(Const):
  20. def get_task_config(self, task_name) -> dict:
  21. match task_name:
  22. case "check_kimi_balance":
  23. expire_duration = self.CHECK_KIMI_BALANCE_TIMEOUT
  24. case "get_off_videos":
  25. expire_duration = self.GET_OFF_VIDEO_TIMEOUT
  26. case "check_publish_video_audit_status":
  27. expire_duration = self.CHECK_VIDEO_AUDIT_TIMEOUT
  28. case "outside_article_monitor":
  29. expire_duration = self.OUTSIDE_ARTICLE_MONITOR_TIMEOUT
  30. case "inner_article_monitor":
  31. expire_duration = self.INNER_ARTICLE_MONITOR_TIMEOUT
  32. case "title_rewrite":
  33. expire_duration = self.TITLE_REWRITE_TIMEOUT
  34. case "daily_publish_articles_recycle":
  35. expire_duration = self.RECYCLE_DAILY_ARTICLE_TIMEOUT
  36. case "update_root_source_id":
  37. expire_duration = self.UPDATE_ROOT_SOURCE_ID_TIMEOUT
  38. case "crawler_toutiao_articles":
  39. expire_duration = self.CRAWLER_TOUTIAO_ARTICLES_TIMEOUT
  40. case _:
  41. expire_duration = self.DEFAULT_TIMEOUT
  42. return {"expire_duration": expire_duration}