MCPcopy Index your code
hub / github.com/simstudioai/sim / updateProcessingIfLeaseHeld

Function updateProcessingIfLeaseHeld

apps/sim/lib/core/outbox/service.ts:500–520  ·  view source on GitHub ↗
(
  event: typeof outboxEvent.$inferSelect,
  patch: {
    attempts: number
    lastError: string
    lockedAt: Date
  }
)

Source from the content-addressed store, hash-verified

498}
499
500async 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
522function runHandlerWithTimeout(
523 handler: OutboxHandler,

Callers 1

recordTimedOutAttemptFunction · 0.85

Calls 3

setMethod · 0.65
eqFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected