job_info.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. from typing import List, Optional
  2. from pydantic import BaseModel
  3. class JobInfoBase(BaseModel):
  4. # 任务执行CRON
  5. job_cron: str
  6. # 任务描述
  7. job_desc: str
  8. # 执行器路由策略
  9. executor_route_strategy: str
  10. # 执行器任务handler
  11. executor_handler: Optional[str]
  12. # 执行器任务参数
  13. executor_param: Optional[str]
  14. # 阻塞处理策略
  15. executor_block_strategy: str
  16. # 任务超时时间, 单位分钟
  17. executor_timeout: int
  18. # 失败重试次数
  19. executor_fail_retry_count: int
  20. # 增量初始时间
  21. inc_start_time: Optional[int]
  22. # datax运行脚本
  23. job_json: str
  24. # 增量时间
  25. replace_param: Optional[str]
  26. # 分区信息
  27. partition_info: Optional[str]
  28. # jvm参数
  29. jvm_param: Optional[str]
  30. class JobInfoCreate(JobInfoBase):
  31. class Config:
  32. schema_extra = {
  33. "example": {
  34. "job_cron": "0 0/2 * * * ?",
  35. "job_desc": "mysql-mysql同步",
  36. "executor_route_strategy": "FIRST",
  37. "executor_handler": "",
  38. "executor_param": "",
  39. "executor_block_strategy": "SERIAL_EXECUTION",
  40. "executor_timeout": 60,
  41. "executor_fail_retry_count": 2,
  42. "inc_start_time": 0,
  43. "job_json": "",
  44. "replace_param": "-DlastTime='%s' -DcurrentTime='%s'",
  45. "partition_info": "txn_date,0,yyyy-MM-dd",
  46. "jvm_param": "",
  47. }
  48. }
  49. class JobInfoUpdate(JobInfoBase):
  50. # 调度状态: 0-停止 1-运行
  51. trigger_status: int
  52. class Config:
  53. schema_extra = {
  54. "example": {
  55. "job_cron": "0 0/2 * * * ?",
  56. "job_desc": "mysql-mysql同步",
  57. "executor_route_strategy": "FIRST",
  58. "executor_handler": "",
  59. "executor_param": "",
  60. "executor_block_strategy": "SERIAL_EXECUTION",
  61. "executor_timeout": 60,
  62. "executor_fail_retry_count": 2,
  63. "inc_start_time": 0,
  64. "job_json": "",
  65. "trigger_status": 1,
  66. "replace_param": "-DlastTime='%s' -DcurrentTime='%s'",
  67. "partition_info": "txn_date,0,yyyy-MM-dd",
  68. "jvm_param": "",
  69. }
  70. }
  71. class JobInfo(JobInfoBase):
  72. id: int
  73. # 创建时间
  74. create_time: int
  75. # 更新时间
  76. update_time: int
  77. # 创建人
  78. user_id: int
  79. # 调度状态: 0-停止 1-运行
  80. trigger_status: int
  81. # 上次调度时间
  82. trigger_last_time: int
  83. # 下次调度时间
  84. trigger_next_time: int
  85. # datax运行脚本
  86. job_json: str
  87. # 最近一次执行状态
  88. last_handle_code: int
  89. class Config:
  90. orm_mode = True