(
executor: Pick<typeof db, 'insert'>,
eventType: string,
payload: T,
options: EnqueueOptions = {}
)
| 96 | * a transaction some other way (or none at all). |
| 97 | */ |
| 98 | export async function enqueueOutboxEvent<T>( |
| 99 | executor: Pick<typeof db, 'insert'>, |
| 100 | eventType: string, |
| 101 | payload: T, |
| 102 | options: EnqueueOptions = {} |
| 103 | ): Promise<string> { |
| 104 | const id = generateId() |
| 105 | await executor.insert(outboxEvent).values({ |
| 106 | id, |
| 107 | eventType, |
| 108 | payload: payload as never, |
| 109 | maxAttempts: options.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, |
| 110 | availableAt: options.availableAt ?? new Date(), |
| 111 | }) |
| 112 | logger.info('Enqueued outbox event', { id, eventType }) |
| 113 | return id |
| 114 | } |
| 115 | |
| 116 | /** Cap on how many dead-lettered rows a single reconciler scan materializes. */ |
| 117 | const DEAD_LETTER_SCAN_LIMIT = 100 |
no test coverage detected