(
event: typeof outboxEvent.$inferSelect,
patch: {
attempts: number
lastError: string
lockedAt: Date
}
)
| 498 | } |
| 499 | |
| 500 | async function updateProcessingIfLeaseHeld( |
| 501 | event: typeof outboxEvent.$inferSelect, |
| 502 | patch: { |
| 503 | attempts: number |
| 504 | lastError: string |
| 505 | lockedAt: Date |
| 506 | } |
| 507 | ): Promise<boolean> { |
| 508 | const whereClauses = [eq(outboxEvent.id, event.id), eq(outboxEvent.status, 'processing')] |
| 509 | if (event.lockedAt) { |
| 510 | whereClauses.push(eq(outboxEvent.lockedAt, event.lockedAt)) |
| 511 | } |
| 512 | |
| 513 | const result = await db |
| 514 | .update(outboxEvent) |
| 515 | .set(patch) |
| 516 | .where(and(...whereClauses)) |
| 517 | .returning({ id: outboxEvent.id }) |
| 518 | |
| 519 | return result.length > 0 |
| 520 | } |
| 521 | |
| 522 | function runHandlerWithTimeout( |
| 523 | handler: OutboxHandler, |
no test coverage detected