(executionId: string)
| 475 | }) |
| 476 | |
| 477 | const heartbeat = (executionId: string): Effect.Effect<void> => |
| 478 | Effect.gen(function*() { |
| 479 | while (true) { |
| 480 | yield* Effect.sleep(heartbeatInterval) |
| 481 | const local = locals.get(executionId) |
| 482 | const polled = local?.fiber?.pollUnsafe() |
| 483 | if (!local?.fiber || polled) return |
| 484 | const cur = yield* readExec(executionId).pipe( |
| 485 | Effect.catchCause(() => Effect.succeed(Option.none<ExecState>())) |
| 486 | ) |
| 487 | if (Option.isNone(cur)) continue |
| 488 | const state = cur.value |
| 489 | if (state.status === "complete" || state.worker !== workerId) return |
| 490 | yield* replaceExec(state, { |
| 491 | leaseExpiresAt: Date.now() + Duration.toMillis(leaseTtl) |
| 492 | }) |
| 493 | .pipe( |
| 494 | Effect.catchTag("OptimisticConcurrencyException", () => Effect.void), |
| 495 | Effect.catchCause(() => Effect.void) |
| 496 | ) |
| 497 | } |
| 498 | }) |
| 499 | |
| 500 | // --- Drive logic ------------------------------------------------------ |
| 501 |
no test coverage detected
searching dependent graphs…