Skip to content

Commit

Permalink
fix: use a shared core module definition object
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 21, 2025
1 parent 3f3e6b0 commit 9725471
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
20 changes: 9 additions & 11 deletions packages/bull/lib/bull.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ import {

@Module({})
export class BullModule {
private static coreModuleDefinition = {
global: true,
module: BullModule,
imports: [DiscoveryModule],
providers: [BullExplorer, BullMetadataAccessor],
};

/**
* Registers a globally available configuration for all queues.
*
Expand Down Expand Up @@ -127,7 +134,7 @@ export class BullModule {
const queueOptionProviders = createQueueOptionProviders([].concat(options));
return {
module: BullModule,
imports: [BullModule.registerCore()],
imports: [BullModule.coreModuleDefinition],
providers: [...queueOptionProviders, ...queueProviders],
exports: queueProviders,
};
Expand All @@ -148,7 +155,7 @@ export class BullModule {
.reduce((a, b) => a.concat(b), []);

return {
imports: imports.concat(BullModule.registerCore()),
imports: imports.concat(BullModule.coreModuleDefinition),
module: BullModule,
providers: [
...asyncQueueOptionsProviders,
Expand Down Expand Up @@ -264,15 +271,6 @@ export class BullModule {
};
}

private static registerCore() {
return {
global: true,
module: BullModule,
imports: [DiscoveryModule],
providers: [BullExplorer, BullMetadataAccessor],
};
}

private static getUniqImports(
options: Array<BullModuleAsyncOptions | SharedBullAsyncConfiguration>,
) {
Expand Down
25 changes: 11 additions & 14 deletions packages/bullmq/lib/bull.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export class BullModule {
private static _queueClass: Type = Queue;
private static _flowProducerClass: Type = FlowProducer;
private static _workerClass: Type = Worker;
private static coreModuleDefinition = {
global: true,
module: BullModule,
imports: [DiscoveryModule],
providers: [BullExplorer, BullMetadataAccessor, BullRegistrar],
exports: [BullRegistrar],
};

/**
* Class to be used to create Bull queues.
Expand Down Expand Up @@ -184,7 +191,7 @@ export class BullModule {

return {
module: BullModule,
imports: [BullModule.registerCore()],
imports: [BullModule.coreModuleDefinition],
providers: [...queueOptionProviders, ...queueProviders],
exports: queueProviders,
};
Expand All @@ -210,7 +217,7 @@ export class BullModule {
.reduce((a, b) => a.concat(b), []);

return {
imports: imports.concat(BullModule.registerCore()),
imports: imports.concat(BullModule.coreModuleDefinition),
module: BullModule,
providers: [
...asyncQueueOptionsProviders,
Expand Down Expand Up @@ -301,7 +308,7 @@ export class BullModule {

return {
module: BullModule,
imports: [BullModule.registerCore()],
imports: [BullModule.coreModuleDefinition],
providers: [...flowProducerOptionProviders, ...flowProducerProviders],
exports: flowProducerProviders,
};
Expand All @@ -324,7 +331,7 @@ export class BullModule {
.reduce((a, b) => a.concat(b), []);

return {
imports: imports.concat(BullModule.registerCore()),
imports: imports.concat(BullModule.coreModuleDefinition),
module: BullModule,
providers: [
...asyncFlowProducerOptionsProviders,
Expand Down Expand Up @@ -456,16 +463,6 @@ export class BullModule {
};
}

private static registerCore() {
return {
global: true,
module: BullModule,
imports: [DiscoveryModule],
providers: [BullExplorer, BullMetadataAccessor, BullRegistrar],
exports: [BullRegistrar],
};
}

private static getUniqImports(
options: Array<RegisterQueueAsyncOptions | SharedBullAsyncConfiguration>,
) {
Expand Down

0 comments on commit 9725471

Please sign in to comment.