feat(category): 类目树、类目属性、属性字典维护系统构建完成
This commit is contained in:
+15
-1
@@ -28,7 +28,7 @@ const connection = new Redis(workerConfig.redisUrl, {
|
||||
});
|
||||
const database = createApplicationDatabase(workerConfig.databaseUrl);
|
||||
const queue = new Queue<OutboxJob>('atlas-dispatch', { connection });
|
||||
const platformQueue = new Queue<PlatformCatalogJob>('atlas-dispatch', { connection });
|
||||
const platformQueue = new Queue<PlatformCatalogJob>('atlas-platform-catalog', { connection });
|
||||
const dispatcher = new OutboxDispatcher(
|
||||
database,
|
||||
queue,
|
||||
@@ -84,6 +84,13 @@ const worker = new Worker<OutboxJob | PlatformCatalogJob>(
|
||||
{ connection, concurrency: 5 },
|
||||
);
|
||||
|
||||
// 平台目录使用独立队列,交互型高优先级刷新不会与素材任务共用等待队列。
|
||||
const platformWorker = new Worker<PlatformCatalogJob>(
|
||||
'atlas-platform-catalog',
|
||||
async (job) => syncPlatformCatalog(database, job.data),
|
||||
{ connection, concurrency: 5 },
|
||||
);
|
||||
|
||||
async function cleanupCollection(database: Database, job: OutboxJob & { payload: { operation_id: string; collection_item_ids: string[] } }) {
|
||||
await database.workspaceTransaction(job.workspaceId, async (tx) => {
|
||||
await tx.query(`UPDATE atlas.operations SET status = 'running', started_at = coalesce(started_at, now()), attempt_count = attempt_count + 1 WHERE id = $1 AND status = 'queued'`, [job.payload.operation_id]);
|
||||
@@ -106,6 +113,10 @@ worker.on('failed', (job, error) => {
|
||||
void markCatalogSyncUnavailable(database, job.data as CatalogSyncJob, error);
|
||||
}
|
||||
});
|
||||
platformWorker.on('failed', (job) => {
|
||||
if (!job || job.attemptsMade < (job.opts.attempts ?? 1)) return;
|
||||
void markPlatformCatalogUnavailable(database, job.data);
|
||||
});
|
||||
|
||||
async function verifyStoreCredentials(database: Database, job: StoreVerificationJob) {
|
||||
const source = await database.workspaceTransaction(
|
||||
@@ -300,7 +311,9 @@ let mediaCleanupTimer: ReturnType<typeof setInterval> | undefined;
|
||||
let platformCatalogTimer: ReturnType<typeof setInterval> | undefined;
|
||||
async function bootstrap() {
|
||||
await queue.waitUntilReady();
|
||||
await platformQueue.waitUntilReady();
|
||||
await worker.waitUntilReady();
|
||||
await platformWorker.waitUntilReady();
|
||||
await dispatcher.dispatchBatch();
|
||||
await platformDispatcher.dispatchBatch();
|
||||
await platformScheduler.run();
|
||||
@@ -359,6 +372,7 @@ async function shutdown() {
|
||||
if (mediaCleanupTimer) clearInterval(mediaCleanupTimer);
|
||||
if (platformCatalogTimer) clearInterval(platformCatalogTimer);
|
||||
await worker.close();
|
||||
await platformWorker.close();
|
||||
await queue.close();
|
||||
await platformQueue.close();
|
||||
objectStorage.destroy();
|
||||
|
||||
Reference in New Issue
Block a user