(executionId: string)
| 338 | * Best-effort: failures are swallowed; loop simply retries on next tick. |
| 339 | */ |
| 340 | const heartbeat = (executionId: string): Effect.Effect<void> => |
| 341 | Effect.gen(function*() { |
| 342 | while (true) { |
| 343 | yield* Effect.sleep(heartbeatInterval) |
| 344 | const local = locals.get(executionId) |
| 345 | const polled = local?.fiber?.pollUnsafe() |
| 346 | if (!local?.fiber || polled) return |
| 347 | const cur = yield* readExec(executionId).pipe( |
| 348 | Effect.catchCause(() => Effect.succeed(Option.none<ExecDoc>())) |
| 349 | ) |
| 350 | if (Option.isNone(cur)) continue |
| 351 | const state = cur.value |
| 352 | if (state.status === "complete" || state.worker !== workerId) return |
| 353 | yield* replaceExec({ |
| 354 | ...state, |
| 355 | leaseExpiresAt: new Date(Date.now() + Duration.toMillis(leaseTtl)).toISOString() |
| 356 | }) |
| 357 | .pipe( |
| 358 | Effect.catchTag("OptimisticConcurrencyException", () => Effect.void), |
| 359 | Effect.catchCause(() => Effect.void) |
| 360 | ) |
| 361 | } |
| 362 | }) |
| 363 | |
| 364 | // --- Drive logic ------------------------------------------------------- |
| 365 |
no test coverage detected
searching dependent graphs…