job_info.py 4.3 KB

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