enhance(Queue): ジョブキューの設定の項目をキューごとに分ける (MisskeyIO#301)
This commit is contained in:
		| @@ -146,7 +146,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 				default: throw new Error(`unrecognized job type ${job.name} for system`); | ||||
| 			} | ||||
| 		}, { | ||||
| 			...baseQueueOptions(this.config, QUEUE.SYSTEM), | ||||
| 			...baseQueueOptions(this.config.redisForSystemQueue, QUEUE.SYSTEM), | ||||
| 			autorun: false, | ||||
| 		}); | ||||
|  | ||||
| @@ -185,7 +185,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 				default: throw new Error(`unrecognized job type ${job.name} for db`); | ||||
| 			} | ||||
| 		}, { | ||||
| 			...baseQueueOptions(this.config, QUEUE.DB), | ||||
| 			...baseQueueOptions(this.config.redisForDbQueue, QUEUE.DB), | ||||
| 			autorun: false, | ||||
| 		}); | ||||
|  | ||||
| @@ -201,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), | ||||
| 			...baseQueueOptions(this.config.redisForDeliverQueue, QUEUE.DELIVER), | ||||
| 			autorun: false, | ||||
| 			concurrency: this.config.deliverJobConcurrency ?? 128, | ||||
| 			limiter: { | ||||
| @@ -225,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), | ||||
| 			...baseQueueOptions(this.config.redisForInboxQueue, QUEUE.INBOX), | ||||
| 			autorun: false, | ||||
| 			concurrency: this.config.inboxJobConcurrency ?? 16, | ||||
| 			limiter: { | ||||
| @@ -249,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), | ||||
| 			...baseQueueOptions(this.config.redisForWebhookDeliverQueue, QUEUE.WEBHOOK_DELIVER), | ||||
| 			autorun: false, | ||||
| 			concurrency: 64, | ||||
| 			limiter: { | ||||
| @@ -281,7 +281,7 @@ export class QueueProcessorService implements OnApplicationShutdown { | ||||
| 				default: throw new Error(`unrecognized job type ${job.name} for relationship`); | ||||
| 			} | ||||
| 		}, { | ||||
| 			...baseQueueOptions(this.config, QUEUE.RELATIONSHIP), | ||||
| 			...baseQueueOptions(this.config.redisForRelationshipQueue, QUEUE.RELATIONSHIP), | ||||
| 			autorun: false, | ||||
| 			concurrency: this.config.relashionshipJobConcurrency ?? 16, | ||||
| 			limiter: { | ||||
| @@ -308,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), | ||||
| 			...baseQueueOptions(this.config.redisForObjectStorageQueue, QUEUE.OBJECT_STORAGE), | ||||
| 			autorun: false, | ||||
| 			concurrency: 16, | ||||
| 		}); | ||||
| @@ -325,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), | ||||
| 			...baseQueueOptions(this.config.redisForEndedPollNotificationQueue, QUEUE.ENDED_POLL_NOTIFICATION), | ||||
| 			autorun: false, | ||||
| 		}); | ||||
| 		//#endregion | ||||
|   | ||||
| @@ -3,8 +3,9 @@ | ||||
|  * SPDX-License-Identifier: AGPL-3.0-only | ||||
|  */ | ||||
|  | ||||
| import { Config } from '@/config.js'; | ||||
| import type * as Bull from 'bullmq'; | ||||
| import type { RedisOptions } from "ioredis"; | ||||
| import type { RedisOptionsSource } from '@/config.js'; | ||||
|  | ||||
| export const QUEUE = { | ||||
| 	DELIVER: 'deliver', | ||||
| @@ -17,13 +18,13 @@ export const QUEUE = { | ||||
| 	WEBHOOK_DELIVER: 'webhookDeliver', | ||||
| }; | ||||
|  | ||||
| export function baseQueueOptions(config: Config, queueName: typeof QUEUE[keyof typeof QUEUE]): Bull.QueueOptions { | ||||
| export function baseQueueOptions(config: RedisOptions & RedisOptionsSource, queueName: typeof QUEUE[keyof typeof QUEUE]): Bull.QueueOptions { | ||||
| 	return { | ||||
| 		connection: { | ||||
| 			...config.redisForJobQueue, | ||||
| 			...config, | ||||
| 			maxRetriesPerRequest: null, | ||||
| 			keyPrefix: undefined, | ||||
| 		}, | ||||
| 		prefix: config.redisForJobQueue.prefix ? `${config.redisForJobQueue.prefix}:queue:${queueName}` : `queue:${queueName}`, | ||||
| 		prefix: config.prefix ? `${config.prefix}:queue:${queueName}` : `queue:${queueName}`, | ||||
| 	}; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 まっちゃとーにゅ
					まっちゃとーにゅ