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
10 changes: 10 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { UserAtprotoIdentityModule } from './user-atproto-identity/user-atproto-
import { AtprotoIdentityModule } from './atproto-identity/atproto-identity.module';
import { MeModule } from './me/me.module';
import { DIDApiModule } from './did-api/did-api.module';
import { ScheduleModule } from '@nestjs/schedule';

const infrastructureDatabaseModule = TypeOrmModule.forRootAsync({
useClass: TypeOrmConfigService,
Expand Down Expand Up @@ -123,6 +124,15 @@ const infrastructureDatabaseModule = TypeOrmModule.forRootAsync({
inject: [ConfigService],
}),
EventEmitterModule.forRoot(),
// The ONLY ScheduleModule registration in the application. forRoot() sets
// global: true and its ScheduleExplorer scans every provider in the
// container, so feature modules import nothing and their @Cron methods are
// still discovered. Two rules follow: calling forRoot() in more than one
// module creates one ScheduleExplorer per call site and fires every cron
// once per call site; and importing the BARE ScheduleModule creates a
// second module whose SchedulerOrchestrator cannot resolve
// SchedulerRegistry (only forRoot() provides it), which fails bootstrap.
ScheduleModule.forRoot(),
ThrottlerModule.forRoot([
{
ttl: 60000, // 60 seconds
Expand Down
4 changes: 2 additions & 2 deletions src/atproto-publisher/atproto-publisher.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Module, forwardRef } from '@nestjs/common';
import { ScheduleModule } from '@nestjs/schedule';
import { AtprotoPublisherService } from './atproto-publisher.service';
import { AtprotoSyncScheduler } from './atproto-sync-scheduler';
import { PdsModule } from '../pds/pds.module';
Expand Down Expand Up @@ -31,7 +30,8 @@ import { TenantModule } from '../tenant/tenant.module';
*/
@Module({
imports: [
ScheduleModule.forRoot(),
// @Cron methods are discovered by the single global
// ScheduleModule.forRoot() in AppModule; no import is needed here.
PdsModule,
forwardRef(() => BlueskyModule),
AtprotoIdentityModule,
Expand Down
2 changes: 0 additions & 2 deletions src/database/database-metrics.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Module } from '@nestjs/common';
import { ScheduleModule } from '@nestjs/schedule';
import { DatabaseMetricsService } from './database-metrics.service';
import {
makeGaugeProvider,
Expand Down Expand Up @@ -57,7 +56,6 @@ const databaseMetricsProviders = [
];

@Module({
imports: [ScheduleModule],
providers: [DatabaseMetricsService, ...databaseMetricsProviders],
exports: [DatabaseMetricsService, ...databaseMetricsProviders],
})
Expand Down
5 changes: 3 additions & 2 deletions src/external-calendar/external-calendar.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Module } from '@nestjs/common';
import { ScheduleModule } from '@nestjs/schedule';
import { ExternalCalendarService } from './external-calendar.service';
import { ExternalCalendarController } from './external-calendar.controller';
import { AvailabilityController } from './availability.controller';
Expand All @@ -10,7 +9,9 @@ import { CalendarSourceModule } from '../calendar-source/calendar-source.module'
import { TenantModule } from '../tenant/tenant.module';

@Module({
imports: [ScheduleModule.forRoot(), TenantModule, CalendarSourceModule],
// @Cron methods are discovered by the single global
// ScheduleModule.forRoot() in AppModule; no import is needed here.
imports: [TenantModule, CalendarSourceModule],
controllers: [ExternalCalendarController, AvailabilityController],
providers: [
ExternalCalendarService,
Expand Down
2 changes: 0 additions & 2 deletions src/matrix/matrix.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Module, forwardRef } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import { TerminusModule } from '@nestjs/terminus';
import { MatrixController } from './matrix.controller';
import { MatrixAppServiceController } from './controllers/matrix-appservice.controller';
Expand Down Expand Up @@ -37,7 +36,6 @@ configureMatrixLogging();
imports: [
ConfigModule.forFeature(matrixConfig),
TerminusModule,
ScheduleModule.forRoot(),
forwardRef(() => UserModule),
TenantModule,
forwardRef(() => AuthModule),
Expand Down
4 changes: 2 additions & 2 deletions src/metrics/metrics.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Module, OnModuleInit } from '@nestjs/common';
import { MetricsService } from './metrics.service';
import { ScheduleModule } from '@nestjs/schedule';
import {
PrometheusModule,
makeGaugeProvider,
Expand Down Expand Up @@ -149,7 +148,8 @@ const atprotoHandleMetrics = [

@Module({
imports: [
ScheduleModule.forRoot(),
// @Cron methods are discovered by the single global
// ScheduleModule.forRoot() in AppModule; no import is needed here.
PrometheusModule.register({
defaultMetrics: {
enabled: true,
Expand Down
Loading