mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
feat(nbstore): add indexer storage (#10953)
This commit is contained in:
@@ -4,10 +4,12 @@ import type { SpaceStorage } from '../storage';
|
||||
import { AwarenessSyncImpl } from './awareness';
|
||||
import { BlobSyncImpl } from './blob';
|
||||
import { DocSyncImpl, type DocSyncState } from './doc';
|
||||
import { IndexerSyncImpl } from './indexer';
|
||||
import type { PeerStorageOptions } from './types';
|
||||
|
||||
export type { BlobSyncState } from './blob';
|
||||
export type { DocSyncDocState, DocSyncState } from './doc';
|
||||
export type { IndexerDocSyncState, IndexerSyncState } from './indexer';
|
||||
|
||||
export interface SyncState {
|
||||
doc?: DocSyncState;
|
||||
@@ -17,6 +19,7 @@ export class Sync {
|
||||
readonly doc: DocSyncImpl;
|
||||
readonly blob: BlobSyncImpl;
|
||||
readonly awareness: AwarenessSyncImpl;
|
||||
readonly indexer: IndexerSyncImpl;
|
||||
|
||||
readonly state$: Observable<SyncState>;
|
||||
|
||||
@@ -26,6 +29,8 @@ export class Sync {
|
||||
const docSync = storages.local.get('docSync');
|
||||
const blobSync = storages.local.get('blobSync');
|
||||
const awareness = storages.local.get('awareness');
|
||||
const indexer = storages.local.get('indexer');
|
||||
const indexerSync = storages.local.get('indexerSync');
|
||||
|
||||
this.doc = new DocSyncImpl(
|
||||
{
|
||||
@@ -60,6 +65,7 @@ export class Sync {
|
||||
])
|
||||
),
|
||||
});
|
||||
this.indexer = new IndexerSyncImpl(doc, indexer, indexerSync);
|
||||
|
||||
this.state$ = this.doc.state$.pipe(map(doc => ({ doc })));
|
||||
}
|
||||
@@ -67,10 +73,12 @@ export class Sync {
|
||||
start() {
|
||||
this.doc?.start();
|
||||
this.blob?.start();
|
||||
this.indexer?.start();
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.doc?.stop();
|
||||
this.blob?.stop();
|
||||
this.indexer?.stop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user