feat(nbstore): new doc sync engine (#8918)

This commit is contained in:
EYHN
2024-12-07 08:05:02 +00:00
parent fafacdb265
commit f54f6e88cb
23 changed files with 1252 additions and 43 deletions
+23
View File
@@ -0,0 +1,23 @@
import type { DocStorage, SpaceStorage } from '../storage';
import { DocSyncEngine } from './doc';
export class SyncEngine {
constructor(
readonly local: SpaceStorage,
readonly peers: SpaceStorage[]
) {}
async run(signal?: AbortSignal) {
const doc = this.local.tryGet('doc');
const sync = this.local.tryGet('sync');
if (doc && sync) {
const peerDocs = this.peers
.map(peer => peer.tryGet('doc'))
.filter((v): v is DocStorage => !!v);
const engine = new DocSyncEngine(doc, sync, peerDocs);
await engine.run(signal);
}
}
}