mirror of
https://github.com/twentyhq/twenty.git
synced 2024-08-17 09:51:03 +03:00
Improve performance/robustness of worker
This commit is contained in:
parent
14cd6f8b6b
commit
25fce27fe3
@ -25,6 +25,7 @@ import { MessageQueueMetadataAccessor } from './message-queue-metadata.accessor'
|
||||
interface ProcessorGroup {
|
||||
instance: object;
|
||||
host: Module;
|
||||
processorName: string;
|
||||
processMethodNames: string[];
|
||||
isRequestScoped: boolean;
|
||||
}
|
||||
@ -77,6 +78,7 @@ export class MessageQueueExplorer implements OnModuleInit {
|
||||
(acc, wrapper) => {
|
||||
const { instance, metatype } = wrapper;
|
||||
const methodNames = this.metadataScanner.getAllMethodNames(instance);
|
||||
const processorName = wrapper.name;
|
||||
const { queueName } =
|
||||
this.metadataAccessor.getProcessorMetadata(
|
||||
instance.constructor || metatype,
|
||||
@ -109,6 +111,7 @@ export class MessageQueueExplorer implements OnModuleInit {
|
||||
acc[queueName].push({
|
||||
instance,
|
||||
host: wrapper.host,
|
||||
processorName,
|
||||
processMethodNames,
|
||||
isRequestScoped: !wrapper.isDependencyTreeStatic(),
|
||||
});
|
||||
@ -137,8 +140,12 @@ export class MessageQueueExplorer implements OnModuleInit {
|
||||
) {
|
||||
queue.work(async (job) => {
|
||||
for (const processorGroup of processorGroupCollection) {
|
||||
const { processorName } = processorGroup;
|
||||
|
||||
if (job.name === processorName) {
|
||||
await this.handleProcessor(processorGroup, job);
|
||||
}
|
||||
}
|
||||
}, options);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user