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:
1 parent
b05807bfc1
commit
74381addc3
21 files changed
+548
-463
No files matched your search
@@ -18,7 +18,7 @@ export type EventMetadata = Record<string, unknown> & {
|
||||
/**
|
||||
* The ID of the event's group. Grouped events are useful when you have distributed transactions
|
||||
* where you need to explicitly group, release and clear events upon lifecycle events of a transaction.
|
||||
*
|
||||
*
|
||||
* When set, you must release the grouped events using the Event Module's `releaseGroupedEvents` method to emit the events.
|
||||
*/
|
||||
eventGroupId?: string
|
||||
@@ -27,7 +27,7 @@ export type EventMetadata = Record<string, unknown> & {
|
||||
export type Event<TData = unknown> = {
|
||||
/**
|
||||
* The event's name.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* user.created
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ export type Event<TData = unknown> = {
|
||||
*/
|
||||
metadata?: EventMetadata
|
||||
/**
|
||||
* The data payload that subscribers receive. For example, the ID of the created user.
|
||||
* The data payload that subscribers receive. For example, the ID or IDs of the created user. (e.g. { id: "123" } or { ids: ["123", "456"] })
|
||||
*/
|
||||
data: TData
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ export function buildModuleResourceEventName({
|
||||
action: string
|
||||
}): string {
|
||||
const kebabCaseName = lowerCaseFirst(kebabCase(objectName))
|
||||
return `${prefix ? `${prefix}.` : ""}${kebabCaseName}.${action}`
|
||||
const conventionalePrefix = prefix && lowerCaseFirst(kebabCase(prefix))
|
||||
return `${prefix ? `${conventionalePrefix}.` : ""}${kebabCaseName}.${action}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,15 +60,15 @@ export function moduleEventBuilderFactory({
|
||||
})
|
||||
}
|
||||
|
||||
data.forEach((dataItem) => {
|
||||
messages.push({
|
||||
source,
|
||||
action,
|
||||
context: sharedContext,
|
||||
data: { id: dataItem.id },
|
||||
eventName: eventName!,
|
||||
object,
|
||||
})
|
||||
messages.push({
|
||||
source,
|
||||
action,
|
||||
context: sharedContext,
|
||||
data: {
|
||||
id: data.length === 1 ? data[0].id : data.map((item) => item.id),
|
||||
},
|
||||
eventName: eventName!,
|
||||
object,
|
||||
})
|
||||
|
||||
aggregator.saveRawMessageData(messages)
|
||||
|
||||
Reference in new issue
Block a user