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

Function heartbeat

packages/infra/src/WorkflowEngineSqlite.ts:477–498  ·  view source on GitHub ↗
(executionId: string)

Source from the content-addressed store, hash-verified

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

Callers 1

driveFunction · 0.70

Calls 7

pollUnsafeMethod · 0.80
readExecFunction · 0.70
replaceExecFunction · 0.70
sleepMethod · 0.65
getMethod · 0.65
pipeMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…