0.6.0 • Published 4 years ago

@targetprocess/event-rectifier v0.6.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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.

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.2

4 years ago