From 8a0a54700cdb946c333788189ac30716812195de Mon Sep 17 00:00:00 2001 From: tamaina Date: Thu, 20 Jul 2023 09:57:37 +0000 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20=E8=A8=AD=E5=AE=9A=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=A7ioredis=E3=81=AE=E5=85=A8?= =?UTF-8?q?=E3=81=A6=E3=81=AE=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=92=E6=8C=87=E5=AE=9A=E5=8F=AF=E8=83=BD=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/example.yml | 9 +++++++++ CHANGELOG.md | 1 + packages/backend/check_connect.js | 1 + packages/backend/src/GlobalModule.ts | 3 +++ packages/backend/src/config.ts | 4 ++++ packages/backend/src/queue/const.ts | 1 + 6 files changed, 19 insertions(+) diff --git a/.config/example.yml b/.config/example.yml index fcf22debce..cbb9c0bd51 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -82,6 +82,9 @@ redis: #pass: example-pass #prefix: example-prefix #db: 1 + # Extra ioredis options + #extra: + # username: example-username #redisForPubsub: # host: localhost @@ -90,6 +93,9 @@ redis: # #pass: example-pass # #prefix: example-prefix # #db: 1 +# # Extra ioredis options +# #extra: +# # username: example-username #redisForJobQueue: # host: localhost @@ -98,6 +104,9 @@ redis: # #pass: example-pass # #prefix: example-prefix # #db: 1 +# # Extra ioredis options +# #extra: +# # username: example-username # ┌───────────────────────────┐ #───┘ MeiliSearch configuration └───────────────────────────── diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b4b2ad31a..57935f0641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,7 @@ ### Server - bullをbull-mqにアップグレードし、ジョブキューのパフォーマンスを改善 - ストリーミングのパフォーマンスを改善 +- 設定ファイルでioredisの全てのオプションを指定可能に (redis.extra) - Fix: 無効化されたアンテナにアクセスがあった際に再度有効化するように - Fix: お知らせの画像URLを空にできない問題を修正 - Fix: i/notificationsのsinceIdが機能しない問題を修正 diff --git a/packages/backend/check_connect.js b/packages/backend/check_connect.js index ef0a350fbf..bea8abb82c 100644 --- a/packages/backend/check_connect.js +++ b/packages/backend/check_connect.js @@ -9,6 +9,7 @@ const redis = new Redis({ password: config.redis.pass, keyPrefix: `${config.redis.prefix}:`, db: config.redis.db ?? 0, + ...(config.redis.extra ?? {}), }); redis.on('connect', () => redis.disconnect()); diff --git a/packages/backend/src/GlobalModule.ts b/packages/backend/src/GlobalModule.ts index 406e3192bb..4b1de080d9 100644 --- a/packages/backend/src/GlobalModule.ts +++ b/packages/backend/src/GlobalModule.ts @@ -48,6 +48,7 @@ const $redis: Provider = { password: config.redis.pass, keyPrefix: `${config.redis.prefix}:`, db: config.redis.db ?? 0, + ...(config.redis.extra ?? {}), }); }, inject: [DI.config], @@ -63,6 +64,7 @@ const $redisForPub: Provider = { password: config.redisForPubsub.pass, keyPrefix: `${config.redisForPubsub.prefix}:`, db: config.redisForPubsub.db ?? 0, + ...(config.redisForPubsub.extra ?? {}), }); return redis; }, @@ -79,6 +81,7 @@ const $redisForSub: Provider = { password: config.redisForPubsub.pass, keyPrefix: `${config.redisForPubsub.prefix}:`, db: config.redisForPubsub.db ?? 0, + ...(config.redisForPubsub.extra ?? {}), }); redis.subscribe(config.host); return redis; diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 8c312256da..d8a8ffbb2a 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -6,6 +6,7 @@ import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; import * as yaml from 'js-yaml'; +import type { RedisOptions } from 'ioredis'; /** * ユーザーが設定する必要のある情報 @@ -42,6 +43,7 @@ export type Source = { pass: string; db?: number; prefix?: string; + extra?: RedisOptions; }; redisForPubsub?: { host: string; @@ -50,6 +52,7 @@ export type Source = { pass: string; db?: number; prefix?: string; + extra?: RedisOptions; }; redisForJobQueue?: { host: string; @@ -58,6 +61,7 @@ export type Source = { pass: string; db?: number; prefix?: string; + extra?: RedisOptions; }; meilisearch?: { host: string; diff --git a/packages/backend/src/queue/const.ts b/packages/backend/src/queue/const.ts index d240fe70e0..4b34daadf3 100644 --- a/packages/backend/src/queue/const.ts +++ b/packages/backend/src/queue/const.ts @@ -20,6 +20,7 @@ export function baseQueueOptions(config: Config, queueName: typeof QUEUE[keyof t family: config.redisForJobQueue.family == null ? 0 : config.redisForJobQueue.family, password: config.redisForJobQueue.pass, db: config.redisForJobQueue.db ?? 0, + ...(config.redisForJobQueue.extra ?? {}), }, prefix: config.redisForJobQueue.prefix ? `${config.redisForJobQueue.prefix}:queue:${queueName}` : `queue:${queueName}`, };