job_info.py 3.2 KB

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