mirror of
https://github.com/immich-app/immich.git
synced 2025-12-02 16:39:56 +09:00
refactor(server): redis config (#13538)
* refactor(server): redis config * refactor: cache parsed env data * chore: add database and redis tests
This commit is contained in:
@@ -3,7 +3,7 @@ import { IoAdapter } from '@nestjs/platform-socket.io';
|
||||
import { createAdapter } from '@socket.io/redis-adapter';
|
||||
import { Redis } from 'ioredis';
|
||||
import { ServerOptions } from 'socket.io';
|
||||
import { parseRedisConfig } from 'src/config';
|
||||
import { IConfigRepository } from 'src/interfaces/config.interface';
|
||||
|
||||
export class WebSocketAdapter extends IoAdapter {
|
||||
constructor(private app: INestApplicationContext) {
|
||||
@@ -11,8 +11,9 @@ export class WebSocketAdapter extends IoAdapter {
|
||||
}
|
||||
|
||||
createIOServer(port: number, options?: ServerOptions): any {
|
||||
const { redis } = this.app.get<IConfigRepository>(IConfigRepository).getEnv();
|
||||
const server = super.createIOServer(port, options);
|
||||
const pubClient = new Redis(parseRedisConfig());
|
||||
const pubClient = new Redis(redis);
|
||||
const subClient = pubClient.duplicate();
|
||||
server.adapter(createAdapter(pubClient, subClient));
|
||||
return server;
|
||||
|
||||
Reference in New Issue
Block a user