feat: async task pipeline for media and llm workflows

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

查看文件

@@ -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;