feat(nbstore): improve nbstore (#9512)

This commit is contained in:
EYHN
2025-01-06 09:38:03 +00:00
parent a2563d2180
commit 46c8c4a408
103 changed files with 3337 additions and 3423 deletions
+18 -6
View File
@@ -3,21 +3,33 @@ import type { BlobSync } from '../sync/blob';
export class BlobFrontend {
constructor(
readonly storage: BlobStorage,
readonly sync?: BlobSync
public readonly storage: BlobStorage,
private readonly sync: BlobSync
) {}
get(blobId: string) {
return this.sync
? this.sync.downloadBlob(blobId)
: this.storage.get(blobId);
return this.sync.downloadBlob(blobId);
}
set(blob: BlobRecord) {
return this.sync ? this.sync.uploadBlob(blob) : this.storage.set(blob);
return this.sync.uploadBlob(blob);
}
fullSync() {
return this.sync.fullSync();
}
addPriority(_id: string, _priority: number) {
// not support yet
}
readonly state$ = this.sync.state$;
setMaxBlobSize(max: number) {
this.sync.setMaxBlobSize(max);
}
onReachedMaxBlobSize(cb: (byteSize: number) => void): () => void {
return this.sync.onReachedMaxBlobSize(cb);
}
}