refactor(server): make redis required module (#9121)

This commit is contained in:
forehalo
2024-12-13 06:27:15 +00:00
parent 81c68032e1
commit 0e73737407
40 changed files with 292 additions and 728 deletions

View File

@@ -175,7 +175,7 @@ export class PgUserspaceDocStorageAdapter extends DocStorageAdapter {
workspaceId: string,
docId: string
) {
const lock = await this.mutex.lock(`userspace:${workspaceId}:${docId}`);
const lock = await this.mutex.acquire(`userspace:${workspaceId}:${docId}`);
if (!lock) {
throw new Error('Too many concurrent writings');

View File

@@ -488,7 +488,7 @@ export class PgWorkspaceDocStorageAdapter extends DocStorageAdapter {
workspaceId: string,
docId: string
) {
const lock = await this.mutex.lock(`doc:update:${workspaceId}:${docId}`);
const lock = await this.mutex.acquire(`doc:update:${workspaceId}:${docId}`);
if (!lock) {
throw new Error('Too many concurrent writings');

View File

@@ -38,7 +38,7 @@ export class CustomSetupController {
throw new PasswordRequired();
}
await using lock = await this.mutex.lock('createFirstAdmin');
await using lock = await this.mutex.acquire('createFirstAdmin');
if (!lock) {
throw new InternalServerError();

View File

@@ -80,7 +80,7 @@ export class TeamWorkspaceResolver {
// lock to prevent concurrent invite
const lockFlag = `invite:${workspaceId}`;
await using lock = await this.mutex.lock(lockFlag);
await using lock = await this.mutex.acquire(lockFlag);
if (!lock) {
return new TooManyRequest();
}
@@ -231,7 +231,7 @@ export class TeamWorkspaceResolver {
try {
// lock to prevent concurrent invite and grant
const lockFlag = `invite:${workspaceId}`;
await using lock = await this.mutex.lock(lockFlag);
await using lock = await this.mutex.acquire(lockFlag);
if (!lock) {
return new TooManyRequest();
}
@@ -281,7 +281,7 @@ export class TeamWorkspaceResolver {
try {
// lock to prevent concurrent invite and grant
const lockFlag = `invite:${workspaceId}`;
await using lock = await this.mutex.lock(lockFlag);
await using lock = await this.mutex.acquire(lockFlag);
if (!lock) {
return new TooManyRequest();
}

View File

@@ -399,7 +399,7 @@ export class WorkspaceResolver {
try {
// lock to prevent concurrent invite and grant
const lockFlag = `invite:${workspaceId}`;
await using lock = await this.mutex.lock(lockFlag);
await using lock = await this.mutex.acquire(lockFlag);
if (!lock) {
return new TooManyRequest();
}
@@ -524,7 +524,7 @@ export class WorkspaceResolver {
@Args('sendAcceptMail', { nullable: true }) sendAcceptMail: boolean
) {
const lockFlag = `invite:${workspaceId}`;
await using lock = await this.mutex.lock(lockFlag);
await using lock = await this.mutex.acquire(lockFlag);
if (!lock) {
return new TooManyRequest();
}