mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 18:02:47 +08:00
refactor(core): initial multiple servers infra (#8745)
This is the initial refactoring of affine to support multiple servers, but many more changes are needed to make multi-server actually work.
This commit is contained in:
@@ -10,6 +10,7 @@ import type {
|
||||
DocStorage,
|
||||
} from '../../../sync';
|
||||
import type { WorkspaceProfileInfo } from '../entities/profile';
|
||||
import type { Workspace } from '../entities/workspace';
|
||||
import type { WorkspaceMetadata } from '../metadata';
|
||||
|
||||
export interface WorkspaceEngineProvider {
|
||||
@@ -55,6 +56,8 @@ export interface WorkspaceFlavourProvider {
|
||||
getWorkspaceBlob(id: string, blob: string): Promise<Blob | null>;
|
||||
|
||||
getEngineProvider(workspaceId: string): WorkspaceEngineProvider;
|
||||
|
||||
onWorkspaceInitialized?(workspace: Workspace): void;
|
||||
}
|
||||
|
||||
export const WorkspaceFlavourProvider =
|
||||
|
||||
@@ -83,11 +83,12 @@ export class WorkspaceRepositoryService extends Service {
|
||||
logger.info(
|
||||
`open workspace [${openOptions.metadata.flavour}] ${openOptions.metadata.id} `
|
||||
);
|
||||
const flavourProvider = this.providers.find(
|
||||
p => p.flavour === openOptions.metadata.flavour
|
||||
);
|
||||
const provider =
|
||||
customProvider ??
|
||||
this.providers
|
||||
.find(p => p.flavour === openOptions.metadata.flavour)
|
||||
?.getEngineProvider(openOptions.metadata.id);
|
||||
flavourProvider?.getEngineProvider(openOptions.metadata.id);
|
||||
if (!provider) {
|
||||
throw new Error(
|
||||
`Unknown workspace flavour: ${openOptions.metadata.flavour}`
|
||||
@@ -106,6 +107,8 @@ export class WorkspaceRepositoryService extends Service {
|
||||
|
||||
this.framework.emitEvent(WorkspaceInitialized, workspace);
|
||||
|
||||
flavourProvider?.onWorkspaceInitialized?.(workspace);
|
||||
|
||||
this.profileRepo
|
||||
.getProfile(openOptions.metadata)
|
||||
.syncWithWorkspace(workspace);
|
||||
|
||||
Reference in New Issue
Block a user