mirror of
https://github.com/immich-app/immich.git
synced 2025-12-03 17:19:52 +09:00
fix(server): Postgres -> Redis websocket (#10801)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { INestApplicationContext } from '@nestjs/common';
|
||||
import { IoAdapter } from '@nestjs/platform-socket.io';
|
||||
import { createAdapter } from '@socket.io/postgres-adapter';
|
||||
import { createAdapter } from '@socket.io/redis-adapter';
|
||||
import { Redis } from 'ioredis';
|
||||
import { ServerOptions } from 'socket.io';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { PostgresDriver } from 'typeorm/driver/postgres/PostgresDriver.js';
|
||||
import { parseRedisConfig } from 'src/config';
|
||||
|
||||
export class WebSocketAdapter extends IoAdapter {
|
||||
constructor(private app: INestApplicationContext) {
|
||||
@@ -12,8 +12,9 @@ export class WebSocketAdapter extends IoAdapter {
|
||||
|
||||
createIOServer(port: number, options?: ServerOptions): any {
|
||||
const server = super.createIOServer(port, options);
|
||||
const pool = (this.app.get(DataSource).driver as PostgresDriver).master;
|
||||
server.adapter(createAdapter(pool));
|
||||
const pubClient = new Redis(parseRedisConfig());
|
||||
const subClient = pubClient.duplicate();
|
||||
server.adapter(createAdapter(pubClient, subClient));
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user