Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getCurrentUserQuery } from '@affine/graphql';
import { JobExecutor } from '../../../base/job/queue/executor';
import { JobHandlerScanner } from '../../../base/job/queue/scanner';
import { DatabaseDocReader, DocReader } from '../../../core/doc';
import { RealtimeGateway } from '../../../core/realtime/gateway';
import { createApp } from '../create-app';
import { e2e } from '../test';

Expand Down Expand Up @@ -43,6 +44,7 @@ e2e('should init worker service', async t => {
const res = await app.GET('/info').expect(200);
t.is(res.body.flavor, 'worker');
t.truthy(app.get(JobHandlerScanner).getHandler('indexer.indexDoc'));
t.throws(() => app.get(RealtimeGateway));

await t.throwsAsync(app.gql({ query: getCurrentUserQuery }));
await app.PUT('/api/storage/upload').expect(404);
Expand All @@ -65,6 +67,7 @@ e2e('should init graphql service', async t => {

const user = await app.gql({ query: getCurrentUserQuery });
t.is(user.currentUser, null);
t.truthy(app.get(RealtimeGateway));
});
});

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { NotificationModule } from './core/notification';
import { PermissionModule } from './core/permission';
import { QueueDashboardModule } from './core/queue-dashboard';
import { QuotaModule } from './core/quota';
import { RealtimeModule } from './core/realtime';
import { RealtimeGatewayModule, RealtimeModule } from './core/realtime';
import { SelfhostModule } from './core/selfhost';
import { StaticFileModule } from './core/static-files';
import { StorageApiModule, StorageWorkerModule } from './core/storage';
Expand Down Expand Up @@ -167,6 +167,7 @@ export function buildAppModule(env: Env) {
factor
// basic
.use(...FunctionalityModules)
.useIf(() => !workerOnly, RealtimeGatewayModule)

// online roles publish indexer events; only the worker registers consumers
.useIf(() => env.isApi || env.isFrontend, IndexerModule)
Expand Down
13 changes: 7 additions & 6 deletions packages/backend/server/src/core/realtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import { RealtimeRegistry } from './registry';

@Global()
@Module({
providers: [
RealtimeRegistry,
RealtimePublisher,
RealtimeGateway,
RealtimeRegistryCompletenessChecker,
],
providers: [RealtimeRegistry, RealtimePublisher],
exports: [RealtimeRegistry, RealtimePublisher],
})
export class RealtimeModule {}

@Module({
imports: [RealtimeModule],
providers: [RealtimeGateway, RealtimeRegistryCompletenessChecker],
})
export class RealtimeGatewayModule {}

export { RealtimeRegistryCompletenessChecker } from './completeness';
export { registerRealtimeLiveQuery } from './provider';
export { RealtimePublisher } from './publisher';
Expand Down
Loading