chore: Ensure the events are emitted with the same shape all accross (#8063)

* chore: Ensure the events are emitted with the same shape all accross

* fixes:

* rm unsues type

* types

* fix tests
This commit is contained in:
Adrien de Peretti
2024-07-10 19:34:28 +02:00
committed by GitHub
parent 95f29358d1
commit e778870c68
9 changed files with 42 additions and 30 deletions

View File

@@ -112,8 +112,8 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
/**
* Emit a single or number of events
* @param {Message} data - the data to send to the subscriber.
* @param {BulkJobOptions} data - the options to add to bull mq
* @param eventsData
* @param options
*/
async emit<T = unknown>(
eventsData: Message<T> | Message<T>[],
@@ -136,10 +136,10 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
for (const event of eventsToGroup) {
const groupId = event.metadata?.eventGroupId!
const array = groupEventsMap.get(groupId) ?? []
const groupEvents = groupEventsMap.get(groupId) ?? []
array.push(event)
groupEventsMap.set(groupId, array)
groupEvents.push(event)
groupEventsMap.set(groupId, groupEvents)
}
const promises: Promise<unknown>[] = []
@@ -258,7 +258,7 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
const subscribersResult = await Promise.all(
subscribersInCurrentAttempt.map(async ({ id, subscriber }) => {
return await subscriber(data, eventName)
return await subscriber(data)
.then(async (data) => {
// For every subscriber that completes successfully, add their id to the list of completed subscribers
completedSubscribersInCurrentAttempt.push(id)