chore: ability to group events on redis event bus (#7655)
* chore: ability to group events on redis event bus * chore: fix tests * Update packages/modules/event-bus-redis/src/services/event-bus-redis.ts Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com> * chore: change shape of input and body data * chore: fix builds * chore: address comments * chore: fix unit test --------- Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
co-authored by
Adrien de Peretti
parent
3b8160b564
commit
39ddba2491
@@ -1,6 +1,6 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { PaymentWebhookEvents } from "@medusajs/utils"
|
||||
import { PaymentModuleOptions } from "@medusajs/types"
|
||||
import { PaymentWebhookEvents } from "@medusajs/utils"
|
||||
|
||||
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
||||
|
||||
@@ -20,10 +20,16 @@ export const POST = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
const eventBus = req.scope.resolve(ModuleRegistrationName.EVENT_BUS)
|
||||
|
||||
// we delay the processing of the event to avoid a conflict caused by a race condition
|
||||
await eventBus.emit(PaymentWebhookEvents.WebhookReceived, event, {
|
||||
delay: options.webhook_delay || 5000,
|
||||
attempts: options.webhook_retries || 3,
|
||||
})
|
||||
await eventBus.emit(
|
||||
{
|
||||
eventName: PaymentWebhookEvents.WebhookReceived,
|
||||
data: event,
|
||||
},
|
||||
{
|
||||
delay: options.webhook_delay || 5000,
|
||||
attempts: options.webhook_retries || 3,
|
||||
}
|
||||
)
|
||||
} catch (err) {
|
||||
res.status(400).send(`Webhook Error: ${err.message}`)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user