Revert "feat(core): run indexer in worker (#7295)"

This reverts commit c62d79ab14.
This commit is contained in:
forehalo
2024-07-03 10:16:27 +08:00
parent fc729d6a32
commit f0d127fa29
13 changed files with 352 additions and 691 deletions

View File

@@ -18,7 +18,6 @@ import {
timer,
} from 'rxjs';
import { MANUALLY_STOP } from '../utils';
import type { LiveData } from './livedata';
/**
@@ -108,8 +107,7 @@ export function fromPromise<T>(
.catch(error => {
subscriber.error(error);
});
return () => abortController.abort(MANUALLY_STOP);
return () => abortController.abort('Aborted');
});
}

View File

@@ -4,7 +4,6 @@ import { difference } from 'lodash-es';
import { LiveData } from '../../livedata';
import type { Memento } from '../../storage';
import { MANUALLY_STOP } from '../../utils';
import { BlobStorageOverCapacity } from './error';
const logger = new DebugLogger('affine:blob-engine');
@@ -71,7 +70,7 @@ export class BlobEngine {
}
stop() {
this.abort?.abort(MANUALLY_STOP);
this.abort?.abort();
this.abort = null;
}

View File

@@ -1,24 +0,0 @@
AFFiNE currently has a lot of data stored using the old ID format. Here, we record the usage of IDs to avoid forgetting.
## Old ID Format
The format is:
- `{workspace-id}:space:{nanoid}` Common
- `{workspace-id}:space:page:{nanoid}`
> Note: sometimes the `workspace-id` is not same with current workspace id.
## Usage
- Local Storage
- indexeddb: Both new and old IDs coexist
- sqlite: Both new and old IDs coexist
- server-clock: Only new IDs are stored
- sync-metadata: Both new and old IDs coexist
- Server Storage
- Only stores new IDs but accepts writes using old IDs
- Protocols
- When the client submits an update, both new and old IDs are used.
- When the server broadcasts updates sent by other clients, both new and old IDs are used.
- When the server responds to `client-pre-sync` (listing all updated docids), only new IDs are used.

View File

@@ -20,9 +20,6 @@ export interface IndexWriter<S extends Schema>
delete(id: string): void;
// TODO(@eyhn)
// deleteByQuery(query: Query<S>): void;
commit(): Promise<void>;
rollback(): void;

View File

@@ -155,9 +155,6 @@ export class IndexedDBJobQueue<J> implements JobQueue<J> {
.objectStore('jobs')
.delete(typeof id === 'string' ? parseInt(id) : id);
}
trx.commit();
this.broadcast.postMessage('job-completed');
}
async return(jobs: Job[], retry: boolean = false): Promise<void> {
@@ -177,10 +174,6 @@ export class IndexedDBJobQueue<J> implements JobQueue<J> {
.delete(typeof id === 'string' ? parseInt(id) : id);
}
}
trx.commit();
this.broadcast.postMessage('job-completed');
}
async clear(): Promise<void> {

View File

@@ -29,7 +29,7 @@ export class JobRunner<J> {
}
stop() {
this.abort?.abort(MANUALLY_STOP);
this.abort?.abort();
this.abort = null;
}