feat(events): Implement default priority-based event processing (#14476)
* feat(events): Set internal events default priority to lowest, default events to 100 and order placed to 10 * Create swift-months-rush.md * improvements * improvements * improvements * fix condition * doc * fix tests * fix tests --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
43951ce60e
commit
7307a5e63f
@@ -6,6 +6,7 @@ import {
|
||||
UsageComputedActions,
|
||||
} from "@medusajs/framework/types"
|
||||
import {
|
||||
EventPriority,
|
||||
isDefined,
|
||||
Modules,
|
||||
OrderStatus,
|
||||
@@ -598,6 +599,9 @@ export const completeCartWorkflow = createWorkflow(
|
||||
emitEventStep({
|
||||
eventName: OrderWorkflowEvents.PLACED,
|
||||
data: { id: createdOrder.id },
|
||||
options: {
|
||||
priority: EventPriority.CRITICAL,
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
EventPriority,
|
||||
Modules,
|
||||
OrderStatus,
|
||||
OrderWorkflowEvents,
|
||||
@@ -180,6 +181,9 @@ export const convertDraftOrderWorkflow = createWorkflow(
|
||||
emitEventStep({
|
||||
eventName: OrderWorkflowEvents.PLACED,
|
||||
data: { id: updatedOrder.id },
|
||||
options: {
|
||||
priority: EventPriority.CRITICAL,
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -87,3 +87,15 @@ export function buildEventNamesFromEntityName<TNames extends string[]>(
|
||||
|
||||
return events as ReturnType<TNames>
|
||||
}
|
||||
|
||||
export const EventPriority = {
|
||||
CRITICAL: 10,
|
||||
HIGH: 50,
|
||||
DEFAULT: 100,
|
||||
LOW: 500,
|
||||
/**
|
||||
* Lowest priority value supported by BullMQ (2^21)
|
||||
* Internal events use this priority to ensure they don't block critical business events
|
||||
*/
|
||||
LOWEST: 2_097_152,
|
||||
} as const
|
||||
|
||||
Reference in New Issue
Block a user