redisForJobQueue の接続を使い回す (MisskeyIO#268)

This commit is contained in:
riku6460 2023-11-27 20:03:00 +09:00 committed by GitHub
parent 107cd9788e
commit 7122657f13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 33 deletions

View file

@ -5,6 +5,7 @@
import { Config } from '@/config.js';
import type * as Bull from 'bullmq';
import type * as Redis from 'ioredis';
export const QUEUE = {
DELIVER: 'deliver',
@ -17,12 +18,9 @@ export const QUEUE = {
WEBHOOK_DELIVER: 'webhookDeliver',
};
export function baseQueueOptions(config: Config, queueName: typeof QUEUE[keyof typeof QUEUE]): Bull.QueueOptions {
export function baseQueueOptions(config: Config, queueName: typeof QUEUE[keyof typeof QUEUE], redisConnection: Redis.Redis): Bull.QueueOptions {
return {
connection: {
...config.redisForJobQueue,
keyPrefix: undefined,
},
connection: redisConnection,
prefix: config.redisForJobQueue.prefix ? `${config.redisForJobQueue.prefix}:queue:${queueName}` : `queue:${queueName}`,
};
}