Add concurrency limit to service

This commit is contained in:
Andras Schmelczer 2024-12-18 20:37:54 +00:00
parent 5bea3c94c1
commit eb87de8e68
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
9 changed files with 116 additions and 58 deletions

View file

@ -1,7 +1,7 @@
import * as lib from "../../../backend/sync_lib/pkg/sync_lib.js";
import { Database } from "src/database/database";
import { Logger } from "src/logger";
import { SyncServer } from "src/services/sync_service";
import { SyncService } from "src/services/sync_service";
import { hash } from "src/utils/hash";
import { unlockDocument, waitForDocumentLock } from "./locks.js";
import { FileOperations } from "src/file-operations/file-operations.js";
@ -16,7 +16,7 @@ export async function syncLocallyCreatedFile({
filePath,
}: {
database: Database;
syncServer: SyncServer;
syncServer: SyncService;
operations: FileOperations;
updateTime: Date;
filePath: RelativePath;

View file

@ -1,14 +1,18 @@
import { Database } from "src/database/database";
import { RelativePath } from "src/database/document-metadata";
import { Logger } from "src/logger";
import { SyncServer } from "src/services/sync_service";
import { SyncService } from "src/services/sync_service";
import { unlockDocument, waitForDocumentLock } from "./locks";
export async function syncLocallyDeletedFile(
database: Database,
syncServer: SyncServer,
relativePath: RelativePath
): Promise<void> {
export async function syncLocallyDeletedFile({
database,
syncServer,
relativePath,
}: {
database: Database;
syncServer: SyncService;
relativePath: RelativePath;
}): Promise<void> {
await waitForDocumentLock(relativePath);
try {

View file

@ -1,7 +1,7 @@
import * as lib from "../../../backend/sync_lib/pkg/sync_lib.js";
import { Database } from "src/database/database";
import { Logger } from "src/logger";
import { SyncServer } from "src/services/sync_service";
import { SyncService } from "src/services/sync_service";
import { hash } from "src/utils/hash";
import { unlockDocument, waitForDocumentLock } from "./locks.js";
import { FileOperations } from "src/file-operations/file-operations.js";
@ -17,7 +17,7 @@ export async function syncLocallyUpdatedFile({
oldPath,
}: {
database: Database;
syncServer: SyncServer;
syncServer: SyncService;
operations: FileOperations;
updateTime: Date;
filePath: RelativePath;

View file

@ -1,6 +1,6 @@
import { Database } from "src/database/database";
import { unlockDocument, waitForDocumentLock } from "./locks";
import { SyncServer } from "src/services/sync_service";
import { SyncService } from "src/services/sync_service";
import * as lib from "../../../backend/sync_lib/pkg/sync_lib.js";
import { hash } from "src/utils/hash";
import { Logger } from "src/logger";
@ -14,7 +14,7 @@ export async function syncRemotelyUpdatedFile({
remoteVersion,
}: {
database: Database;
syncServer: SyncServer;
syncServer: SyncService;
operations: FileOperations;
remoteVersion: components["schemas"]["DocumentVersionWithoutContent"];
}): Promise<void> {