Revert "enhance(backend): redisForJobQueue の接続を使い回す (MisskeyIO#268)" (MisskeyIO#292)
This reverts commit 7122657f13.
			
			
This commit is contained in:
		| @@ -5,7 +5,6 @@ | ||||
|  | ||||
| import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common'; | ||||
| import * as Bull from 'bullmq'; | ||||
| import * as Redis from 'ioredis'; | ||||
| import type { Config } from '@/config.js'; | ||||
| import { DI } from '@/di-symbols.js'; | ||||
| import type Logger from '@/logger.js'; | ||||
| @@ -85,9 +84,6 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 		@Inject(DI.config) | ||||
| 		private config: Config, | ||||
|  | ||||
| 		@Inject(DI.redisForJobQueue) | ||||
| 		private redisForJobQueue: Redis.Redis, | ||||
|  | ||||
| 		private queueLoggerService: QueueLoggerService, | ||||
| 		private webhookDeliverProcessorService: WebhookDeliverProcessorService, | ||||
| 		private endedPollNotificationProcessorService: EndedPollNotificationProcessorService, | ||||
| @@ -150,7 +146,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 				default: throw new Error(`unrecognized job type ${job.name} for system`); | ||||
| 			} | ||||
| 		}, { | ||||
| 			...baseQueueOptions(this.config, QUEUE.SYSTEM, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.SYSTEM), | ||||
| 			autorun: false, | ||||
| 		}); | ||||
|  | ||||
| @@ -189,7 +185,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 				default: throw new Error(`unrecognized job type ${job.name} for db`); | ||||
| 			} | ||||
| 		}, { | ||||
| 			...baseQueueOptions(this.config, QUEUE.DB, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.DB), | ||||
| 			autorun: false, | ||||
| 		}); | ||||
|  | ||||
| @@ -205,7 +201,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
|  | ||||
| 		//#region deliver | ||||
| 		this.deliverQueueWorker = new Bull.Worker(QUEUE.DELIVER, (job) => this.deliverProcessorService.process(job), { | ||||
| 			...baseQueueOptions(this.config, QUEUE.DELIVER, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.DELIVER), | ||||
| 			autorun: false, | ||||
| 			concurrency: this.config.deliverJobConcurrency ?? 128, | ||||
| 			limiter: { | ||||
| @@ -229,7 +225,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
|  | ||||
| 		//#region inbox | ||||
| 		this.inboxQueueWorker = new Bull.Worker(QUEUE.INBOX, (job) => this.inboxProcessorService.process(job), { | ||||
| 			...baseQueueOptions(this.config, QUEUE.INBOX, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.INBOX), | ||||
| 			autorun: false, | ||||
| 			concurrency: this.config.inboxJobConcurrency ?? 16, | ||||
| 			limiter: { | ||||
| @@ -253,7 +249,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
|  | ||||
| 		//#region webhook deliver | ||||
| 		this.webhookDeliverQueueWorker = new Bull.Worker(QUEUE.WEBHOOK_DELIVER, (job) => this.webhookDeliverProcessorService.process(job), { | ||||
| 			...baseQueueOptions(this.config, QUEUE.WEBHOOK_DELIVER, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.WEBHOOK_DELIVER), | ||||
| 			autorun: false, | ||||
| 			concurrency: 64, | ||||
| 			limiter: { | ||||
| @@ -285,7 +281,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 				default: throw new Error(`unrecognized job type ${job.name} for relationship`); | ||||
| 			} | ||||
| 		}, { | ||||
| 			...baseQueueOptions(this.config, QUEUE.RELATIONSHIP, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.RELATIONSHIP), | ||||
| 			autorun: false, | ||||
| 			concurrency: this.config.relashionshipJobConcurrency ?? 16, | ||||
| 			limiter: { | ||||
| @@ -312,7 +308,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 				default: throw new Error(`unrecognized job type ${job.name} for objectStorage`); | ||||
| 			} | ||||
| 		}, { | ||||
| 			...baseQueueOptions(this.config, QUEUE.OBJECT_STORAGE, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.OBJECT_STORAGE), | ||||
| 			autorun: false, | ||||
| 			concurrency: 16, | ||||
| 		}); | ||||
| @@ -329,7 +325,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
|  | ||||
| 		//#region ended poll notification | ||||
| 		this.endedPollNotificationQueueWorker = new Bull.Worker(QUEUE.ENDED_POLL_NOTIFICATION, (job) => this.endedPollNotificationProcessorService.process(job), { | ||||
| 			...baseQueueOptions(this.config, QUEUE.ENDED_POLL_NOTIFICATION, this.redisForJobQueue), | ||||
| 			...baseQueueOptions(this.config, QUEUE.ENDED_POLL_NOTIFICATION), | ||||
| 			autorun: false, | ||||
| 		}); | ||||
| 		//#endregion | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
|  | ||||
| import { Config } from '@/config.js'; | ||||
| import type * as Bull from 'bullmq'; | ||||
| import type * as Redis from 'ioredis'; | ||||
|  | ||||
| export const QUEUE = { | ||||
| 	DELIVER: 'deliver', | ||||
| @@ -18,9 +17,13 @@ export const QUEUE = { | ||||
| 	WEBHOOK_DELIVER: 'webhookDeliver', | ||||
| }; | ||||
|  | ||||
| export function baseQueueOptions(config: Config, queueName: typeof QUEUE[keyof typeof QUEUE], redisConnection: Redis.Redis): Bull.QueueOptions { | ||||
| export function baseQueueOptions(config: Config, queueName: typeof QUEUE[keyof typeof QUEUE]): Bull.QueueOptions { | ||||
| 	return { | ||||
| 		connection: redisConnection, | ||||
| 		connection: { | ||||
| 			...config.redisForJobQueue, | ||||
| 			maxRetriesPerRequest: null, | ||||
| 			keyPrefix: undefined, | ||||
| 		}, | ||||
| 		prefix: config.redisForJobQueue.prefix ? `${config.redisForJobQueue.prefix}:queue:${queueName}` : `queue:${queueName}`, | ||||
| 	}; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 まっちゃとーにゅ
					まっちゃとーにゅ