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 18:57:08 +02:00
committed by GitHub
parent b05807bfc1
commit 74381addc3
21 changed files with 548 additions and 463 deletions

View File

@@ -461,7 +461,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
)
const events = eventBusEmitSpy.mock.calls[0][0]
expect(events).toHaveLength(4)
expect(events).toHaveLength(3)
expect(events[0]).toEqual(
composeMessage(PricingEvents.PRICE_LIST_CREATED, {
source: Modules.PRICING,
@@ -475,18 +475,15 @@ moduleIntegrationTestRunner<IPricingModuleService>({
source: Modules.PRICING,
action: CommonEvents.CREATED,
object: "price_list_rule",
data: { id: priceList.price_list_rules?.[0].id },
data: {
id: [
priceList.price_list_rules?.[0].id,
priceList.price_list_rules?.[1].id,
],
},
})
)
expect(events[2]).toEqual(
composeMessage(PricingEvents.PRICE_LIST_RULE_CREATED, {
source: Modules.PRICING,
action: CommonEvents.CREATED,
object: "price_list_rule",
data: { id: priceList.price_list_rules?.[1].id },
})
)
expect(events[3]).toEqual(
composeMessage(PricingEvents.PRICE_CREATED, {
source: Modules.PRICING,
action: CommonEvents.CREATED,

View File

@@ -1003,12 +1003,12 @@ export default class PricingModuleService
})
// Bulk create price sets
const createdPriceSets = await this.priceSetService_.create(
const priceSets = await this.priceSetService_.create(
toCreate,
sharedContext
)
const eventsData = createdPriceSets.reduce(
const eventsData = priceSets.reduce(
(eventsData, priceSet) => {
eventsData.priceSets.push({
id: priceSet.id,
@@ -1051,7 +1051,7 @@ export default class PricingModuleService
sharedContext,
})
return createdPriceSets
return priceSets
}
@InjectTransactionManager()