feat: async task pipeline for media and llm workflows

这个提交包含在:
cryptocommuniums-afk
2026-03-15 00:12:26 +08:00
父节点 1cc863e60e
当前提交 20e183d2da
修改 36 个文件,包含 1961 行新增339 行删除

查看文件

@@ -0,0 +1,22 @@
CREATE TABLE `background_tasks` (
`id` varchar(36) NOT NULL,
`userId` int NOT NULL,
`type` enum('media_finalize','training_plan_generate','training_plan_adjust','analysis_corrections','pose_correction_multimodal') NOT NULL,
`status` enum('queued','running','succeeded','failed') NOT NULL DEFAULT 'queued',
`title` varchar(256) NOT NULL,
`message` text,
`progress` int NOT NULL DEFAULT 0,
`payload` json NOT NULL,
`result` json,
`error` text,
`attempts` int NOT NULL DEFAULT 0,
`maxAttempts` int NOT NULL DEFAULT 3,
`workerId` varchar(96),
`runAfter` timestamp NOT NULL DEFAULT (now()),
`lockedAt` timestamp,
`startedAt` timestamp,
`completedAt` timestamp,
`createdAt` timestamp NOT NULL DEFAULT (now()),
`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT `background_tasks_id` PRIMARY KEY(`id`)
);

查看文件

@@ -36,6 +36,13 @@
"when": 1773490358606,
"tag": "0004_exotic_randall",
"breakpoints": true
},
{
"idx": 5,
"version": "5",
"when": 1773504000000,
"tag": "0005_lively_taskmaster",
"breakpoints": true
}
]
}
}

查看文件

@@ -301,3 +301,36 @@ export const notificationLog = mysqlTable("notification_log", {
export type NotificationLogEntry = typeof notificationLog.$inferSelect;
export type InsertNotificationLog = typeof notificationLog.$inferInsert;
/**
* Background task queue for long-running or retryable work.
*/
export const backgroundTasks = mysqlTable("background_tasks", {
id: varchar("id", { length: 36 }).primaryKey(),
userId: int("userId").notNull(),
type: mysqlEnum("type", [
"media_finalize",
"training_plan_generate",
"training_plan_adjust",
"analysis_corrections",
"pose_correction_multimodal",
]).notNull(),
status: mysqlEnum("status", ["queued", "running", "succeeded", "failed"]).notNull().default("queued"),
title: varchar("title", { length: 256 }).notNull(),
message: text("message"),
progress: int("progress").notNull().default(0),
payload: json("payload").notNull(),
result: json("result"),
error: text("error"),
attempts: int("attempts").notNull().default(0),
maxAttempts: int("maxAttempts").notNull().default(3),
workerId: varchar("workerId", { length: 96 }),
runAfter: timestamp("runAfter").defaultNow().notNull(),
lockedAt: timestamp("lockedAt"),
startedAt: timestamp("startedAt"),
completedAt: timestamp("completedAt"),
createdAt: timestamp("createdAt").defaultNow().notNull(),
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
});
export type BackgroundTask = typeof backgroundTasks.$inferSelect;
export type InsertBackgroundTask = typeof backgroundTasks.$inferInsert;