job_log.py 2.1 KB

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