job_info.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. # 分区时间格式
  28. partition_time: Optional[str]
  29. # 分区时间倒退天数
  30. partition_num: Optional[int]
  31. # jvm参数
  32. jvm_param: Optional[str]
  33. # 上次时间字段
  34. last_time: Optional[str]
  35. # 当前时间字段
  36. current_time: Optional[str]
  37. class JobInfoCreate(JobInfoBase):
  38. # 周期表达式
  39. cron_expression: CronExpression
  40. class Config:
  41. schema_extra = {
  42. "example": {
  43. "cron_expression": {
  44. "cron_select_type": 3,
  45. "cron_expression": "",
  46. "minute": 0,
  47. "hour": 0,
  48. "day": 1,
  49. "week": 3,
  50. "month": 2,
  51. },
  52. "job_desc": "mysql-mysql同步",
  53. "executor_route_strategy": "FIRST",
  54. "executor_handler": "",
  55. "executor_param": "",
  56. "executor_block_strategy": "SERIAL_EXECUTION",
  57. "executor_timeout": 60,
  58. "executor_fail_retry_count": 2,
  59. "inc_start_time": 0,
  60. "job_json": "",
  61. "replace_param": "-DlastTime='%s' -DcurrentTime='%s'",
  62. "partition_info": "txn_date",
  63. "partition_time": "yyyy-MM-dd",
  64. "partition_num": 0,
  65. "jvm_param": "",
  66. "last_time": "lastTime",
  67. "current_time": "currentTime",
  68. }
  69. }
  70. class JobInfoUpdate(JobInfoBase):
  71. # 周期表达式
  72. cron_expression: CronExpression
  73. # 调度状态: 0-停止 1-运行
  74. trigger_status: int
  75. class Config:
  76. schema_extra = {
  77. "example": {
  78. "cron_expression": {
  79. "cron_select_type": 3,
  80. "cron_expression": "",
  81. "minute": 0,
  82. "hour": 0,
  83. "day": 1,
  84. "week": 3,
  85. "month": 2,
  86. },
  87. "job_desc": "mysql-mysql同步",
  88. "executor_route_strategy": "FIRST",
  89. "executor_handler": "",
  90. "executor_param": "",
  91. "executor_block_strategy": "SERIAL_EXECUTION",
  92. "executor_timeout": 60,
  93. "executor_fail_retry_count": 2,
  94. "inc_start_time": 0,
  95. "job_json": "",
  96. "trigger_status": 1,
  97. "replace_param": "-DlastTime='%s' -DcurrentTime='%s'",
  98. "partition_info": "txn_date",
  99. "partition_time": "yyyy-MM-dd",
  100. "partition_num": 0,
  101. "jvm_param": "",
  102. "last_time": "lastTime",
  103. "current_time": "currentTime",
  104. }
  105. }
  106. class JobInfo(JobInfoBase):
  107. id: int
  108. user_id: str
  109. # 创建时间
  110. create_time: int
  111. # 更新时间
  112. update_time: int
  113. # 调度状态: 0-停止 1-运行
  114. trigger_status: int
  115. # 上次调度时间
  116. trigger_last_time: int
  117. # 下次调度时间
  118. trigger_next_time: int
  119. # datax运行脚本
  120. job_json: str
  121. # 最近一次执行状态
  122. last_handle_code: int
  123. # 运行周期
  124. job_cron: str
  125. class Config:
  126. orm_mode = True
  127. class JobInfoTriggerStatus(BaseModel):
  128. # 任务id
  129. id: int
  130. # 调度状态: 0-停止 1-运行
  131. trigger_status: int
  132. class Config:
  133. schema_extra = {
  134. "example": {
  135. "id": 1,
  136. "trigger_status": 0,
  137. }
  138. }