feat: standalone collab server (#767)

* feat: standalone collab server

* * custom collab server port env
* fix collab start script command

* * API prefix
* Log startup PORT

* Tweak collab debounce
This commit is contained in:
Philip Okugbe
2025-02-25 13:15:51 +00:00
committed by GitHub
parent 08829ea721
commit 4b9ab4f63c
10 changed files with 119 additions and 22 deletions

View File

@ -25,21 +25,25 @@ export class CollaborationGateway {
this.redisConfig = parseRedisUrl(this.environmentService.getRedisUrl());
this.hocuspocus = HocuspocusServer.configure({
debounce: 5000,
maxDebounce: 10000,
debounce: 10000,
maxDebounce: 20000,
unloadImmediately: false,
extensions: [
this.authenticationExtension,
this.persistenceExtension,
new Redis({
host: this.redisConfig.host,
port: this.redisConfig.port,
options: {
password: this.redisConfig.password,
db: this.redisConfig.db,
retryStrategy: createRetryStrategy(),
},
}),
...(this.environmentService.isCollabDisableRedis()
? []
: [
new Redis({
host: this.redisConfig.host,
port: this.redisConfig.port,
options: {
password: this.redisConfig.password,
db: this.redisConfig.db,
retryStrategy: createRetryStrategy(),
},
}),
]),
],
});
}
@ -48,6 +52,14 @@ export class CollaborationGateway {
this.hocuspocus.handleConnection(client, request);
}
getConnectionCount() {
return this.hocuspocus.getConnectionsCount();
}
getDocumentCount() {
return this.hocuspocus.getDocumentsCount();
}
async destroy(): Promise<void> {
await this.hocuspocus.destroy();
}