job_log.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. from typing import List, Optional
  2. from pydantic import BaseModel
  3. class JobLogBase(BaseModel):
  4. # 执行器主键ID
  5. job_group: int
  6. # 任务主键ID
  7. job_id: int
  8. # 执行器地址,本次执行的地址
  9. executor_address: Optional[str]
  10. # 执行器任务handler
  11. executor_handler: Optional[str]
  12. # 执行器任务参数
  13. executor_param: str
  14. # 执行器任务分片参数,格式如1/2
  15. executor_sharding_param: str
  16. # 失败重试次数
  17. executor_fail_retry_count: int
  18. # 告警状态:0-默认、1-无需告警、2-告警成功、3-告警失败
  19. alarm_status: int
  20. class JobLogCreate(JobLogBase):
  21. class Config:
  22. schema_extra = {
  23. "example": {
  24. "job_group": 1,
  25. "job_id": 1,
  26. "executor_address": "FIRST",
  27. "executor_handler": "",
  28. "executor_param": "",
  29. "executor_sharding_param": "1/2",
  30. "executor_fail_retry_count": 3,
  31. "alarm_status": 0
  32. }
  33. }
  34. class JobLogTriggerUpdate():
  35. # 调度时间
  36. trigger_time: int
  37. # 调度结果
  38. trigger_code: int
  39. # 调度日志
  40. trigger_msg: str
  41. class Config:
  42. schema_extra = {
  43. "example": {
  44. "trigger_time": 1588888888,
  45. "trigger_code": 1,
  46. "trigger_msg": "",
  47. }
  48. }
  49. class JobLogHandleUpdate():
  50. # 执行时间
  51. handle_time: int
  52. # 执行状态
  53. handle_code: int
  54. # 执行日志
  55. handle_msg: str
  56. class Config:
  57. schema_extra = {
  58. "example": {
  59. "handle_time": 1588888888,
  60. "handle_code": 1,
  61. "handle_msg": "",
  62. }
  63. }
  64. class JobLog(JobLogBase):
  65. id: int
  66. # 上次调度时间
  67. trigger_time: int
  68. # 调度状态: 0-停止 1-运行
  69. trigger_code: int
  70. # 上次调度时间
  71. trigger_msg: str
  72. # 执行时间
  73. handle_time: int
  74. # 执行状态
  75. handle_code: int
  76. # 执行日志
  77. handle_msg: str
  78. # datax 进程ID
  79. process_id: str
  80. class Config:
  81. orm_mode = True