job_info.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. cron_expression: CronExpression
  7. # 任务描述
  8. job_desc: str
  9. # 执行器路由策略
  10. executor_route_strategy: str
  11. # 执行器任务handler
  12. executor_handler: Optional[str]
  13. # 执行器任务参数
  14. executor_param: Optional[str]
  15. # 阻塞处理策略
  16. executor_block_strategy: str
  17. # 任务超时时间, 单位分钟
  18. executor_timeout: int
  19. # 失败重试次数
  20. executor_fail_retry_count: int
  21. # 增量初始时间
  22. inc_start_time: Optional[int]
  23. # datax运行脚本
  24. job_json: str
  25. # 增量时间
  26. replace_param: Optional[str]
  27. # 分区信息
  28. partition_info: Optional[str]
  29. # jvm参数
  30. jvm_param: Optional[str]
  31. class JobInfoCreate(JobInfoBase):
  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. # 调度状态: 0-停止 1-运行
  60. trigger_status: int
  61. class Config:
  62. schema_extra = {
  63. "example": {
  64. "cron_expression": {
  65. "cron_select_type": 3,
  66. "cron_expression": "",
  67. "minute": 0,
  68. "hour": 0,
  69. "day": 1,
  70. "week": 3,
  71. "month": 2,
  72. },
  73. "job_desc": "mysql-mysql同步",
  74. "executor_route_strategy": "FIRST",
  75. "executor_handler": "",
  76. "executor_param": "",
  77. "executor_block_strategy": "SERIAL_EXECUTION",
  78. "executor_timeout": 60,
  79. "executor_fail_retry_count": 2,
  80. "inc_start_time": 0,
  81. "job_json": "",
  82. "trigger_status": 1,
  83. "replace_param": "-DlastTime='%s' -DcurrentTime='%s'",
  84. "partition_info": "txn_date,0,yyyy-MM-dd",
  85. "jvm_param": "",
  86. }
  87. }
  88. class JobInfo(JobInfoBase):
  89. id: int
  90. # 创建时间
  91. create_time: int
  92. # 更新时间
  93. update_time: int
  94. # 创建人
  95. user_id: int
  96. # 调度状态: 0-停止 1-运行
  97. trigger_status: int
  98. # 上次调度时间
  99. trigger_last_time: int
  100. # 下次调度时间
  101. trigger_next_time: int
  102. # datax运行脚本
  103. job_json: str
  104. # 最近一次执行状态
  105. last_handle_code: int
  106. # 运行周期
  107. job_cron: str
  108. class Config:
  109. orm_mode = True