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:
EYHN
2024-11-27 06:44:46 +00:00
parent 3f4cb5be40
commit 6b4a1aa917
80 changed files with 1141 additions and 519 deletions

View File

@@ -1,12 +1,12 @@
export { WorkspaceShareSettingService } from './services/share-setting';
import { GraphQLService } from '@affine/core/modules/cloud';
import {
type Framework,
WorkspaceScope,
WorkspaceService,
} from '@toeverything/infra';
import { WorkspaceServerService } from '../cloud';
import { WorkspaceShareSetting } from './entities/share-setting';
import { WorkspaceShareSettingService } from './services/share-setting';
import { WorkspaceShareSettingStore } from './stores/share-setting';
@@ -15,7 +15,7 @@ export function configureShareSettingModule(framework: Framework) {
framework
.scope(WorkspaceScope)
.service(WorkspaceShareSettingService)
.store(WorkspaceShareSettingStore, [GraphQLService])
.store(WorkspaceShareSettingStore, [WorkspaceServerService])
.entity(WorkspaceShareSetting, [
WorkspaceService,
WorkspaceShareSettingStore,

View File

@@ -1,4 +1,4 @@
import type { GraphQLService } from '@affine/core/modules/cloud';
import type { WorkspaceServerService } from '@affine/core/modules/cloud';
import {
getEnableUrlPreviewQuery,
setEnableUrlPreviewMutation,
@@ -6,7 +6,7 @@ import {
import { Store } from '@toeverything/infra';
export class WorkspaceShareSettingStore extends Store {
constructor(private readonly graphqlService: GraphQLService) {
constructor(private readonly workspaceServerService: WorkspaceServerService) {
super();
}
@@ -14,7 +14,10 @@ export class WorkspaceShareSettingStore extends Store {
workspaceId: string,
signal?: AbortSignal
) {
const data = await this.graphqlService.gql({
if (!this.workspaceServerService.server) {
throw new Error('No Server');
}
const data = await this.workspaceServerService.server.gql({
query: getEnableUrlPreviewQuery,
variables: {
id: workspaceId,
@@ -31,7 +34,10 @@ export class WorkspaceShareSettingStore extends Store {
enableUrlPreview: boolean,
signal?: AbortSignal
) {
await this.graphqlService.gql({
if (!this.workspaceServerService.server) {
throw new Error('No Server');
}
await this.workspaceServerService.server.gql({
query: setEnableUrlPreviewMutation,
variables: {
id: workspaceId,