enhance(backend): 設定ファイルでioredisの全てのオプションを指定可能に

This commit is contained in:
tamaina 2023-07-20 09:57:37 +00:00
parent 47b684100d
commit 8a0a54700c
6 changed files with 19 additions and 0 deletions

View File

@ -82,6 +82,9 @@ redis:
#pass: example-pass #pass: example-pass
#prefix: example-prefix #prefix: example-prefix
#db: 1 #db: 1
# Extra ioredis options
#extra:
# username: example-username
#redisForPubsub: #redisForPubsub:
# host: localhost # host: localhost
@ -90,6 +93,9 @@ redis:
# #pass: example-pass # #pass: example-pass
# #prefix: example-prefix # #prefix: example-prefix
# #db: 1 # #db: 1
# # Extra ioredis options
# #extra:
# # username: example-username
#redisForJobQueue: #redisForJobQueue:
# host: localhost # host: localhost
@ -98,6 +104,9 @@ redis:
# #pass: example-pass # #pass: example-pass
# #prefix: example-prefix # #prefix: example-prefix
# #db: 1 # #db: 1
# # Extra ioredis options
# #extra:
# # username: example-username
# ┌───────────────────────────┐ # ┌───────────────────────────┐
#───┘ MeiliSearch configuration └───────────────────────────── #───┘ MeiliSearch configuration └─────────────────────────────

View File

@ -124,6 +124,7 @@
### Server ### Server
- bullをbull-mqにアップグレードし、ジョブキューのパフォーマンスを改善 - bullをbull-mqにアップグレードし、ジョブキューのパフォーマンスを改善
- ストリーミングのパフォーマンスを改善 - ストリーミングのパフォーマンスを改善
- 設定ファイルでioredisの全てのオプションを指定可能に (redis.extra)
- Fix: 無効化されたアンテナにアクセスがあった際に再度有効化するように - Fix: 無効化されたアンテナにアクセスがあった際に再度有効化するように
- Fix: お知らせの画像URLを空にできない問題を修正 - Fix: お知らせの画像URLを空にできない問題を修正
- Fix: i/notificationsのsinceIdが機能しない問題を修正 - Fix: i/notificationsのsinceIdが機能しない問題を修正

View File

@ -9,6 +9,7 @@ const redis = new Redis({
password: config.redis.pass, password: config.redis.pass,
keyPrefix: `${config.redis.prefix}:`, keyPrefix: `${config.redis.prefix}:`,
db: config.redis.db ?? 0, db: config.redis.db ?? 0,
...(config.redis.extra ?? {}),
}); });
redis.on('connect', () => redis.disconnect()); redis.on('connect', () => redis.disconnect());

View File

@ -48,6 +48,7 @@ const $redis: Provider = {
password: config.redis.pass, password: config.redis.pass,
keyPrefix: `${config.redis.prefix}:`, keyPrefix: `${config.redis.prefix}:`,
db: config.redis.db ?? 0, db: config.redis.db ?? 0,
...(config.redis.extra ?? {}),
}); });
}, },
inject: [DI.config], inject: [DI.config],
@ -63,6 +64,7 @@ const $redisForPub: Provider = {
password: config.redisForPubsub.pass, password: config.redisForPubsub.pass,
keyPrefix: `${config.redisForPubsub.prefix}:`, keyPrefix: `${config.redisForPubsub.prefix}:`,
db: config.redisForPubsub.db ?? 0, db: config.redisForPubsub.db ?? 0,
...(config.redisForPubsub.extra ?? {}),
}); });
return redis; return redis;
}, },
@ -79,6 +81,7 @@ const $redisForSub: Provider = {
password: config.redisForPubsub.pass, password: config.redisForPubsub.pass,
keyPrefix: `${config.redisForPubsub.prefix}:`, keyPrefix: `${config.redisForPubsub.prefix}:`,
db: config.redisForPubsub.db ?? 0, db: config.redisForPubsub.db ?? 0,
...(config.redisForPubsub.extra ?? {}),
}); });
redis.subscribe(config.host); redis.subscribe(config.host);
return redis; return redis;

View File

@ -6,6 +6,7 @@ import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path'; import { dirname, resolve } from 'node:path';
import * as yaml from 'js-yaml'; import * as yaml from 'js-yaml';
import type { RedisOptions } from 'ioredis';
/** /**
* *
@ -42,6 +43,7 @@ export type Source = {
pass: string; pass: string;
db?: number; db?: number;
prefix?: string; prefix?: string;
extra?: RedisOptions;
}; };
redisForPubsub?: { redisForPubsub?: {
host: string; host: string;
@ -50,6 +52,7 @@ export type Source = {
pass: string; pass: string;
db?: number; db?: number;
prefix?: string; prefix?: string;
extra?: RedisOptions;
}; };
redisForJobQueue?: { redisForJobQueue?: {
host: string; host: string;
@ -58,6 +61,7 @@ export type Source = {
pass: string; pass: string;
db?: number; db?: number;
prefix?: string; prefix?: string;
extra?: RedisOptions;
}; };
meilisearch?: { meilisearch?: {
host: string; host: string;

View File

@ -20,6 +20,7 @@ export function baseQueueOptions(config: Config, queueName: typeof QUEUE[keyof t
family: config.redisForJobQueue.family == null ? 0 : config.redisForJobQueue.family, family: config.redisForJobQueue.family == null ? 0 : config.redisForJobQueue.family,
password: config.redisForJobQueue.pass, password: config.redisForJobQueue.pass,
db: config.redisForJobQueue.db ?? 0, db: config.redisForJobQueue.db ?? 0,
...(config.redisForJobQueue.extra ?? {}),
}, },
prefix: config.redisForJobQueue.prefix ? `${config.redisForJobQueue.prefix}:queue:${queueName}` : `queue:${queueName}`, prefix: config.redisForJobQueue.prefix ? `${config.redisForJobQueue.prefix}:queue:${queueName}` : `queue:${queueName}`,
}; };