重构模型平台前后端并移除Redis依赖
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# Database Event Schemas
|
||||
|
||||
内部事件以 JSON Schema Draft 2020-12 定义:
|
||||
|
||||
- `event-envelope-v1.json`:公共事件信封;
|
||||
- `schedule-run-requested-v1.json`:请求启动一次调度运行;
|
||||
- `job-node-execute-v1.json`:请求执行一个稳定版本节点;
|
||||
- `job-node-finished-v1.json`:节点终态。
|
||||
|
||||
事件先随业务事务写入 MySQL `outbox_events`,Schedule Executor 直接轮询处理;
|
||||
`consumer_inbox` 提供幂等保护。字段和状态值不得在生产者或消费者中另行定义。
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "event-envelope-v1.json",
|
||||
"title": "Model Platform Event Envelope V1",
|
||||
"description": "MySQL Outbox 中所有内部业务事件共用的不可变信封。",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"event_id",
|
||||
"event_type",
|
||||
"schema_version",
|
||||
"occurred_at",
|
||||
"producer",
|
||||
"trace_id",
|
||||
"aggregate_type",
|
||||
"aggregate_id",
|
||||
"idempotency_key",
|
||||
"payload"
|
||||
],
|
||||
"properties": {
|
||||
"event_id": {
|
||||
"$ref": "#/$defs/ulid"
|
||||
},
|
||||
"event_type": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z][a-z0-9]*(\\.[a-z][a-z0-9_]*)+$"
|
||||
},
|
||||
"schema_version": {
|
||||
"const": 1
|
||||
},
|
||||
"occurred_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"producer": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 64
|
||||
},
|
||||
"trace_id": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 64
|
||||
},
|
||||
"aggregate_type": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 64
|
||||
},
|
||||
"aggregate_id": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 128
|
||||
},
|
||||
"idempotency_key": {
|
||||
"type": "string",
|
||||
"minLength": 8,
|
||||
"maxLength": 128
|
||||
},
|
||||
"payload": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"ulid": {
|
||||
"type": "string",
|
||||
"minLength": 26,
|
||||
"maxLength": 26,
|
||||
"pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "job-node-execute-v1.json",
|
||||
"title": "Job Node Execute V1",
|
||||
"description": "调度编排器请求 Job Worker 执行一个稳定版本节点。",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "event-envelope-v1.json"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"event_type": {
|
||||
"const": "job.node.execute"
|
||||
},
|
||||
"aggregate_type": {
|
||||
"const": "schedule_node_run"
|
||||
},
|
||||
"payload": {
|
||||
"$ref": "job-node-execute-v1.json#/$defs/payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"$defs": {
|
||||
"ulid": {
|
||||
"type": "string",
|
||||
"minLength": 26,
|
||||
"maxLength": 26,
|
||||
"pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
|
||||
},
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"workspace_id",
|
||||
"run_id",
|
||||
"node_run_id",
|
||||
"node_id",
|
||||
"versions_id",
|
||||
"attempt_no",
|
||||
"script_type",
|
||||
"artifact_object_id",
|
||||
"artifact_path",
|
||||
"timeout_seconds",
|
||||
"arguments"
|
||||
],
|
||||
"properties": {
|
||||
"workspace_id": {
|
||||
"$ref": "job-node-execute-v1.json#/$defs/ulid"
|
||||
},
|
||||
"run_id": {
|
||||
"$ref": "job-node-execute-v1.json#/$defs/ulid"
|
||||
},
|
||||
"node_run_id": {
|
||||
"$ref": "job-node-execute-v1.json#/$defs/ulid"
|
||||
},
|
||||
"node_id": {
|
||||
"$ref": "job-node-execute-v1.json#/$defs/ulid"
|
||||
},
|
||||
"versions_id": {
|
||||
"$ref": "job-node-execute-v1.json#/$defs/ulid"
|
||||
},
|
||||
"attempt_no": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 11
|
||||
},
|
||||
"script_type": {
|
||||
"enum": [
|
||||
"python",
|
||||
"notebook"
|
||||
]
|
||||
},
|
||||
"artifact_object_id": {
|
||||
"$ref": "job-node-execute-v1.json#/$defs/ulid"
|
||||
},
|
||||
"artifact_path": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 1024
|
||||
},
|
||||
"timeout_seconds": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 86400
|
||||
},
|
||||
"arguments": {
|
||||
"type": "array",
|
||||
"maxItems": 100,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": [
|
||||
{
|
||||
"event_id": "01K123456789ABCDEFGHJKMNPZ",
|
||||
"event_type": "job.node.execute",
|
||||
"schema_version": 1,
|
||||
"occurred_at": "2026-07-27T08:00:01Z",
|
||||
"producer": "schedule-orchestrator",
|
||||
"trace_id": "req-demo-0001",
|
||||
"aggregate_type": "schedule_node_run",
|
||||
"aggregate_id": "01K123456789ABCDEFGHJKMNQ0",
|
||||
"idempotency_key": "01K123456789ABCDEFGHJKMNQ0:1",
|
||||
"payload": {
|
||||
"workspace_id": "01K123456789ABCDEFGHJKMNPS",
|
||||
"run_id": "01K123456789ABCDEFGHJKMNPR",
|
||||
"node_run_id": "01K123456789ABCDEFGHJKMNQ0",
|
||||
"node_id": "01K123456789ABCDEFGHJKMNPW",
|
||||
"versions_id": "01K123456789ABCDEFGHJKMNPX",
|
||||
"attempt_no": 1,
|
||||
"script_type": "python",
|
||||
"artifact_object_id": "01K123456789ABCDEFGHJKMNPY",
|
||||
"artifact_path": "versions/prepare/v1.py",
|
||||
"timeout_seconds": 600,
|
||||
"arguments": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "job-node-finished-v1.json",
|
||||
"title": "Job Node Finished V1",
|
||||
"description": "Job Worker 报告一次节点执行的终态,调度编排器据此推进 DAG。",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "event-envelope-v1.json"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"event_type": {
|
||||
"const": "job.node.finished"
|
||||
},
|
||||
"aggregate_type": {
|
||||
"const": "schedule_node_run"
|
||||
},
|
||||
"payload": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"$defs": {
|
||||
"ulid": {
|
||||
"type": "string",
|
||||
"minLength": 26,
|
||||
"maxLength": 26,
|
||||
"pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
|
||||
},
|
||||
"nullableUlid": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "job-node-finished-v1.json#/$defs/ulid"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"workspace_id",
|
||||
"run_id",
|
||||
"node_run_id",
|
||||
"node_id",
|
||||
"versions_id",
|
||||
"attempt_no",
|
||||
"node_status",
|
||||
"exit_code",
|
||||
"started_at",
|
||||
"finished_at",
|
||||
"duration_ms",
|
||||
"logs_object_id",
|
||||
"result_object_id",
|
||||
"error_code",
|
||||
"error_message"
|
||||
],
|
||||
"properties": {
|
||||
"workspace_id": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/ulid"
|
||||
},
|
||||
"run_id": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/ulid"
|
||||
},
|
||||
"node_run_id": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/ulid"
|
||||
},
|
||||
"node_id": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/ulid"
|
||||
},
|
||||
"versions_id": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/ulid"
|
||||
},
|
||||
"attempt_no": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 11
|
||||
},
|
||||
"node_status": {
|
||||
"enum": [
|
||||
"succeeded",
|
||||
"failed",
|
||||
"cancelled",
|
||||
"timed_out"
|
||||
]
|
||||
},
|
||||
"exit_code": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"started_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"finished_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"duration_ms": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"logs_object_id": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/nullableUlid"
|
||||
},
|
||||
"result_object_id": {
|
||||
"$ref": "job-node-finished-v1.json#/$defs/nullableUlid"
|
||||
},
|
||||
"error_code": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"maxLength": 64
|
||||
},
|
||||
"error_message": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"maxLength": 2000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": [
|
||||
{
|
||||
"event_id": "01K123456789ABCDEFGHJKMNQ1",
|
||||
"event_type": "job.node.finished",
|
||||
"schema_version": 1,
|
||||
"occurred_at": "2026-07-27T08:00:03Z",
|
||||
"producer": "job-worker",
|
||||
"trace_id": "req-demo-0001",
|
||||
"aggregate_type": "schedule_node_run",
|
||||
"aggregate_id": "01K123456789ABCDEFGHJKMNQ0",
|
||||
"idempotency_key": "01K123456789ABCDEFGHJKMNQ0:1:finished",
|
||||
"payload": {
|
||||
"workspace_id": "01K123456789ABCDEFGHJKMNPS",
|
||||
"run_id": "01K123456789ABCDEFGHJKMNPR",
|
||||
"node_run_id": "01K123456789ABCDEFGHJKMNQ0",
|
||||
"node_id": "01K123456789ABCDEFGHJKMNPW",
|
||||
"versions_id": "01K123456789ABCDEFGHJKMNPX",
|
||||
"attempt_no": 1,
|
||||
"node_status": "succeeded",
|
||||
"exit_code": 0,
|
||||
"started_at": "2026-07-27T08:00:01Z",
|
||||
"finished_at": "2026-07-27T08:00:03Z",
|
||||
"duration_ms": 2000,
|
||||
"logs_object_id": null,
|
||||
"result_object_id": null,
|
||||
"error_code": null,
|
||||
"error_message": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "schedule-run-requested-v1.json",
|
||||
"title": "Schedule Run Requested V1",
|
||||
"description": "Platform API 或 Cron Dispatcher 请求调度编排器启动一次固化 DAG。",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "event-envelope-v1.json"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"event_type": {
|
||||
"const": "schedule.run.requested"
|
||||
},
|
||||
"aggregate_type": {
|
||||
"const": "schedule_run"
|
||||
},
|
||||
"payload": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"$defs": {
|
||||
"ulid": {
|
||||
"type": "string",
|
||||
"minLength": 26,
|
||||
"maxLength": 26,
|
||||
"pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
|
||||
},
|
||||
"node": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"node_id",
|
||||
"node_key",
|
||||
"versions_id",
|
||||
"script_type",
|
||||
"artifact_object_id",
|
||||
"artifact_path",
|
||||
"timeout_seconds",
|
||||
"retry_count",
|
||||
"retry_interval_sec",
|
||||
"arguments"
|
||||
],
|
||||
"properties": {
|
||||
"node_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
"node_key": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 64
|
||||
},
|
||||
"versions_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
"script_type": {
|
||||
"enum": [
|
||||
"python",
|
||||
"notebook"
|
||||
]
|
||||
},
|
||||
"artifact_object_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
"artifact_path": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 1024
|
||||
},
|
||||
"timeout_seconds": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 86400
|
||||
},
|
||||
"retry_count": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 10
|
||||
},
|
||||
"retry_interval_sec": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 3600
|
||||
},
|
||||
"arguments": {
|
||||
"type": "array",
|
||||
"maxItems": 100,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"edge": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"source_node_id",
|
||||
"target_node_id"
|
||||
],
|
||||
"properties": {
|
||||
"source_node_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
"target_node_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
}
|
||||
}
|
||||
},
|
||||
"snapshot": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schedule_name",
|
||||
"workflow_version",
|
||||
"max_concurrency",
|
||||
"failure_policy",
|
||||
"nodes",
|
||||
"edges"
|
||||
],
|
||||
"properties": {
|
||||
"schedule_name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 255
|
||||
},
|
||||
"workflow_version": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"max_concurrency": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 100
|
||||
},
|
||||
"failure_policy": {
|
||||
"enum": [
|
||||
"stop",
|
||||
"continue"
|
||||
]
|
||||
},
|
||||
"nodes": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"maxItems": 100,
|
||||
"items": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/node"
|
||||
}
|
||||
},
|
||||
"edges": {
|
||||
"type": "array",
|
||||
"maxItems": 500,
|
||||
"items": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/edge"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"workspace_id",
|
||||
"schedule_id",
|
||||
"run_id",
|
||||
"workflow_version",
|
||||
"trigger_type",
|
||||
"triggered_by",
|
||||
"schedule_snapshot"
|
||||
],
|
||||
"properties": {
|
||||
"workspace_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
"schedule_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
"run_id": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
"workflow_version": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"trigger_type": {
|
||||
"enum": [
|
||||
"manual",
|
||||
"cron",
|
||||
"api",
|
||||
"retry"
|
||||
]
|
||||
},
|
||||
"triggered_by": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/ulid"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"schedule_snapshot": {
|
||||
"$ref": "schedule-run-requested-v1.json#/$defs/snapshot"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": [
|
||||
{
|
||||
"event_id": "01K123456789ABCDEFGHJKMNPQ",
|
||||
"event_type": "schedule.run.requested",
|
||||
"schema_version": 1,
|
||||
"occurred_at": "2026-07-27T08:00:00Z",
|
||||
"producer": "platform-api",
|
||||
"trace_id": "req-demo-0001",
|
||||
"aggregate_type": "schedule_run",
|
||||
"aggregate_id": "01K123456789ABCDEFGHJKMNPR",
|
||||
"idempotency_key": "run-demo-0001",
|
||||
"payload": {
|
||||
"workspace_id": "01K123456789ABCDEFGHJKMNPS",
|
||||
"schedule_id": "01K123456789ABCDEFGHJKMNPT",
|
||||
"run_id": "01K123456789ABCDEFGHJKMNPR",
|
||||
"workflow_version": 1,
|
||||
"trigger_type": "manual",
|
||||
"triggered_by": "01K123456789ABCDEFGHJKMNPV",
|
||||
"schedule_snapshot": {
|
||||
"schedule_name": "每日模型演示",
|
||||
"workflow_version": 1,
|
||||
"max_concurrency": 1,
|
||||
"failure_policy": "stop",
|
||||
"nodes": [
|
||||
{
|
||||
"node_id": "01K123456789ABCDEFGHJKMNPW",
|
||||
"node_key": "prepare",
|
||||
"versions_id": "01K123456789ABCDEFGHJKMNPX",
|
||||
"script_type": "python",
|
||||
"artifact_object_id": "01K123456789ABCDEFGHJKMNPY",
|
||||
"artifact_path": "versions/prepare/v1.py",
|
||||
"timeout_seconds": 600,
|
||||
"retry_count": 0,
|
||||
"retry_interval_sec": 5,
|
||||
"arguments": []
|
||||
}
|
||||
],
|
||||
"edges": []
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user