chore(): Emit events in batch and index process event ids in batch (#12097)

**What**
First iteration to prevent events from overwhelming the systems.
- Group emitted event ids when possible instead of creating a message per id which leads to reduced amount of events to process massively in cases of import for example
- Update the index engine to process event data in batches of 100
- Update event handling by the index engine to be able to upsert by batch as well
- Fix index engine build config for intermediate listeners inferrence
This commit is contained in:
Adrien de Peretti
2025-04-08 16:57:08 +00:00
committed by GitHub
parent b05807bfc1
commit 74381addc3
21 changed files with 548 additions and 463 deletions
@@ -5,7 +5,11 @@ import {
ModuleJoinerConfig,
ModuleJoinerRelationship,
} from "@medusajs/framework/types"
import { CommonEvents, GraphQLUtils } from "@medusajs/framework/utils"
import {
buildModuleResourceEventName,
CommonEvents,
GraphQLUtils,
} from "@medusajs/framework/utils"
import { schemaObjectRepresentationPropertiesToOmit } from "@types"
export const CustomDirectives = {
@@ -561,9 +565,23 @@ function processEntity(
intermediateEntityObjectRepresentationRef.alias =
intermediateEntityAlias
intermediateEntityObjectRepresentationRef.listeners = [
intermediateEntityName + "." + CommonEvents.CREATED,
intermediateEntityName + "." + CommonEvents.UPDATED,
buildModuleResourceEventName({
action: CommonEvents.CREATED,
objectName: intermediateEntityName,
prefix: intermediateEntityModule.serviceName,
}),
buildModuleResourceEventName({
action: CommonEvents.UPDATED,
objectName: intermediateEntityName,
prefix: intermediateEntityModule.serviceName,
}),
buildModuleResourceEventName({
action: CommonEvents.DELETED,
objectName: intermediateEntityName,
prefix: intermediateEntityModule.serviceName,
}),
]
intermediateEntityObjectRepresentationRef.moduleConfig =
intermediateEntityModule