MCPcopy Create free account
hub / github.com/effect-app/libs / tryClaim

Function tryClaim

packages/infra/src/WorkflowEngineSqlite.ts:463–475  ·  view source on GitHub ↗
(state: ExecState)

Source from the content-addressed store, hash-verified

461 && state.leaseExpiresAt > now
462
463 const tryClaim = (state: ExecState): Effect.Effect<Option.Option<ExecState>> =>
464 Effect.gen(function*() {
465 const now = Date.now()
466 if (leaseActive(state, now)) return Option.none<ExecState>()
467 return yield* replaceExec(state, {
468 worker: workerId,
469 leaseExpiresAt: now + Duration.toMillis(leaseTtl)
470 })
471 .pipe(
472 Effect.map(Option.some),
473 Effect.catchTag("OptimisticConcurrencyException", () => Effect.succeed(Option.none<ExecState>()))
474 )
475 })
476
477 const heartbeat = (executionId: string): Effect.Effect<void> =>
478 Effect.gen(function*() {

Callers 1

driveFunction · 0.70

Calls 5

leaseActiveFunction · 0.70
replaceExecFunction · 0.70
pipeMethod · 0.65
mapMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…