mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
[post-modularisation]Removed Redis from CE (#12695)
* Removed redis init from ce * Added server file
This commit is contained in:
parent
91a1720185
commit
c1f7de98eb
2 changed files with 2 additions and 30 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 580c287986ae9dffe6580a6c6a6840dbcd18fd80
|
||||
Subproject commit d25a63dc72c911dbd2973973861c63f62990efde
|
||||
|
|
@ -1,39 +1,11 @@
|
|||
import http from 'http';
|
||||
import { WebSocketGateway, WebSocketServer, OnGatewayConnection, OnGatewayDisconnect } from '@nestjs/websockets';
|
||||
import { Server } from 'ws';
|
||||
import { setupWSConnection, setPersistence } from 'y-websocket/bin/utils';
|
||||
import { RedisPubSub } from '../../helpers/redis';
|
||||
import { setupWSConnection } from 'y-websocket/bin/utils';
|
||||
import { maybeSetSubPath } from '../../helpers/utils.helper';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { SessionUtilService } from '@modules/session/util.service';
|
||||
|
||||
// TODO: Mock redis for test env
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
const redis = new RedisPubSub({
|
||||
redisOpts: process.env.REDIS_URL
|
||||
? process.env.REDIS_URL
|
||||
: {
|
||||
host: process.env.REDIS_HOST || 'localhost',
|
||||
port: process.env.REDIS_PORT || 6379,
|
||||
username: process.env.REDIS_USER || '',
|
||||
password: process.env.REDIS_PASSWORD || '',
|
||||
},
|
||||
});
|
||||
|
||||
setPersistence({
|
||||
provider: redis,
|
||||
bindState: async (docName: any, ydoc: any) => {
|
||||
const persistedYdoc = redis.bindState(docName, ydoc);
|
||||
ydoc.on('update', persistedYdoc.updateHandler);
|
||||
ydoc.awareness.on('update', (update, conn) => persistedYdoc.updateAwarenessHandler(ydoc.awareness, update, conn));
|
||||
},
|
||||
writeState: (docName: any, ydoc: any) => {
|
||||
return new Promise((resolve) => {
|
||||
resolve(redis.closeDoc(docName));
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@WebSocketGateway({ path: maybeSetSubPath('/yjs') })
|
||||
export class YjsGateway implements OnGatewayConnection, OnGatewayDisconnect {
|
||||
|
|
|
|||
Loading…
Reference in a new issue