feat(nbstore): add blob sync frontend (#9084)

This commit is contained in:
EYHN
2024-12-11 12:39:26 +00:00
parent a67fbc9448
commit 0c0722c650
3 changed files with 54 additions and 3 deletions
@@ -0,0 +1,23 @@
import type { BlobRecord, BlobStorage } from '../storage';
import type { BlobSyncEngine } from '../sync/blob';
export class BlobFrontend {
constructor(
readonly storage: BlobStorage,
readonly sync?: BlobSyncEngine
) {}
get(blobId: string) {
return this.sync
? this.sync.downloadBlob(blobId)
: this.storage.get(blobId);
}
set(blob: BlobRecord) {
return this.sync ? this.sync.uploadBlob(blob) : this.storage.set(blob);
}
addPriority(id: string, priority: number) {
return this.sync?.addPriority(id, priority);
}
}