2023-08-15 02:52:38 +09:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-05-29 11:54:49 +09:00
|
|
|
import type * as Bull from 'bullmq';
|
2023-12-29 14:58:35 +09:00
|
|
|
import type { RedisOptions } from "ioredis";
|
|
|
|
import type { RedisOptionsSource } from '@/config.js';
|
2023-05-29 11:54:49 +09:00
|
|
|
|
|
|
|
export const QUEUE = {
|
|
|
|
DELIVER: 'deliver',
|
|
|
|
INBOX: 'inbox',
|
|
|
|
SYSTEM: 'system',
|
|
|
|
ENDED_POLL_NOTIFICATION: 'endedPollNotification',
|
|
|
|
DB: 'db',
|
|
|
|
RELATIONSHIP: 'relationship',
|
|
|
|
OBJECT_STORAGE: 'objectStorage',
|
|
|
|
WEBHOOK_DELIVER: 'webhookDeliver',
|
|
|
|
};
|
|
|
|
|
2023-12-29 14:58:35 +09:00
|
|
|
export function baseQueueOptions(config: RedisOptions & RedisOptionsSource, queueName: typeof QUEUE[keyof typeof QUEUE]): Bull.QueueOptions {
|
2023-05-29 11:54:49 +09:00
|
|
|
return {
|
2023-12-28 05:33:22 +09:00
|
|
|
connection: {
|
2023-12-29 14:58:35 +09:00
|
|
|
...config,
|
2023-12-28 05:33:22 +09:00
|
|
|
maxRetriesPerRequest: null,
|
|
|
|
keyPrefix: undefined,
|
|
|
|
},
|
2023-12-29 14:58:35 +09:00
|
|
|
prefix: config.prefix ? `${config.prefix}:queue:${queueName}` : `queue:${queueName}`,
|
2023-05-29 11:54:49 +09:00
|
|
|
};
|
|
|
|
}
|
2024-01-01 02:57:23 +09:00
|
|
|
|
|
|
|
export function baseWorkerOptions(config: RedisOptions & RedisOptionsSource, queueName: typeof QUEUE[keyof typeof QUEUE]): Bull.WorkerOptions {
|
|
|
|
return {
|
|
|
|
connection: {
|
|
|
|
...config,
|
|
|
|
maxRetriesPerRequest: null,
|
|
|
|
keyPrefix: undefined,
|
|
|
|
},
|
|
|
|
prefix: config.prefix ? `${config.prefix}:queue:${queueName}` : `queue:${queueName}`,
|
|
|
|
skipLockRenewal: false,
|
|
|
|
lockDuration: 60 * 1000,
|
|
|
|
lockRenewTime: 30 * 1000,
|
|
|
|
stalledInterval: 90 * 1000,
|
|
|
|
};
|
|
|
|
}
|