(state: ExecState)
| 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*() { |
no test coverage detected
searching dependent graphs…