mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
Some checks are pending
Document deploy / sync-images (push) Waiting to run
Document deploy / generate-timestamp (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.cn suffix:cn]) (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.io suffix:io]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.cn kube_config:KUBE_CONFIG_CN suffix:cn]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.io kube_config:KUBE_CONFIG_IO suffix:io]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / get-vars (push) Waiting to run
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:amd64 runs-on:ubuntu-24.04]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / release-fastgpt-images (push) Blocked by required conditions
* stop design doc * perf: init worker * perf: remove dataset cide * remove invalid doc
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { getQueue, getWorker, QueueNames } from '../../../common/bullmq';
|
||
import { datasetDeleteProcessor } from './processor';
|
||
|
||
export type DatasetDeleteJobData = {
|
||
teamId: string;
|
||
datasetId: string;
|
||
};
|
||
|
||
// 创建工作进程
|
||
export const initDatasetDeleteWorker = () => {
|
||
return getWorker<DatasetDeleteJobData>(QueueNames.datasetDelete, datasetDeleteProcessor, {
|
||
concurrency: 1, // 确保同时只有1个删除任务
|
||
removeOnFail: {
|
||
age: 30 * 24 * 60 * 60 // 保留30天失败记录
|
||
}
|
||
});
|
||
};
|
||
|
||
// 添加删除任务
|
||
export const addDatasetDeleteJob = (data: DatasetDeleteJobData) => {
|
||
// 创建删除队列
|
||
const datasetDeleteQueue = getQueue<DatasetDeleteJobData>(QueueNames.datasetDelete, {
|
||
defaultJobOptions: {
|
||
attempts: 10,
|
||
backoff: {
|
||
type: 'exponential',
|
||
delay: 5000
|
||
},
|
||
removeOnComplete: true,
|
||
removeOnFail: { age: 30 * 24 * 60 * 60 } // 保留30天失败记录
|
||
}
|
||
});
|
||
|
||
const jobId = `${String(data.teamId)}:${String(data.datasetId)}`;
|
||
|
||
// 使用去重机制,避免重复删除
|
||
return datasetDeleteQueue.add('delete_dataset', data, {
|
||
jobId,
|
||
delay: 1000 // 延迟1秒执行,确保API响应完成
|
||
});
|
||
};
|