mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00: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:
parent
79acbc1d7b
commit
3f663106e8
8 changed files with 318 additions and 173 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue