mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 21:38:44 +08:00
feat(nbstore): add nbstore worker (#9185)
This commit is contained in:
@@ -17,7 +17,13 @@ export interface DocSyncDocState {
|
||||
errorMessage: string | null;
|
||||
}
|
||||
|
||||
export class DocSync {
|
||||
export interface DocSync {
|
||||
readonly state$: Observable<DocSyncState>;
|
||||
docState$(docId: string): Observable<DocSyncDocState>;
|
||||
addPriority(id: string, priority: number): () => void;
|
||||
}
|
||||
|
||||
export class DocSyncImpl implements DocSync {
|
||||
private readonly peers: DocSyncPeer[] = this.remotes.map(
|
||||
remote => new DocSyncPeer(this.local, this.sync, remote)
|
||||
);
|
||||
|
||||
@@ -92,7 +92,7 @@ export class DocSyncPeer {
|
||||
/**
|
||||
* random unique id for recognize self in "update" event
|
||||
*/
|
||||
private readonly uniqueId = `sync:${this.local.peer}:${this.remote.peer}:${nanoid()}`;
|
||||
private readonly uniqueId = `sync:${this.local.universalId}:${this.remote.universalId}:${nanoid()}`;
|
||||
private readonly prioritySettings = new Map<string, number>();
|
||||
|
||||
constructor(
|
||||
@@ -435,7 +435,6 @@ export class DocSyncPeer {
|
||||
};
|
||||
|
||||
async mainLoop(signal?: AbortSignal) {
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
try {
|
||||
await this.retryLoop(signal);
|
||||
@@ -594,12 +593,12 @@ export class DocSyncPeer {
|
||||
}
|
||||
|
||||
// begin to process jobs
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
|
||||
while (true) {
|
||||
throwIfAborted(signal);
|
||||
|
||||
const docId = await this.status.jobDocQueue.asyncPop(signal);
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
|
||||
while (true) {
|
||||
// batch process jobs for the same doc
|
||||
const jobs = this.status.jobMap.get(docId);
|
||||
|
||||
Reference in New Issue
Block a user