@targetprocess/event-rectifier
v0.6.0
Published
Allow processing events with different designators in parallel and one by one for the same
Downloads
559
Readme
event-rectifier
Allow processing events with different designators in parallel and one by one for the same.
usage
Here is example how use it with Rabbit:
const eventRectifier = new EventRectifier()
const consumeId = await ch.consume(
GenericEventsQueueName,
async msg => {
if (!msg) {
throw new Error('Consumption was canceled by the rabbit.')
}
try {
const event: EntityChangeEvent = JSON.parse(msg.content.toString())
await eventRectifier.executeRectified(
async e => {
// process event here
},
event.account, // this is event parallel creteria
event
)
ch.ack(msg)
} catch (e) {
handleError(msg, e)
}
},
{ noAck: false }
)
In this example events will be splited by account. Events with the same account will be executed one by one, events with different accounts could be executed in parallel.