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

Function waitForComplete

packages/infra/test/workflow-engine-cosmos.test.ts:94–109  ·  view source on GitHub ↗
(
  workflow: { readonly poll: (id: string) => Effect.Effect<Option.Option<Workflow.Result<any, any>>, never, any> },
  executionId: string,
  step = Duration.millis(10),
  maxIterations = 200
)

Source from the content-addressed store, hash-verified

92
93// Helper that polls until the workflow completes (or `maxIterations` elapse).
94const waitForComplete = (
95 workflow: { readonly poll: (id: string) => Effect.Effect<Option.Option<Workflow.Result<any, any>>, never, any> },
96 executionId: string,
97 step = Duration.millis(10),
98 maxIterations = 200
99) =>
100 Effect.gen(function*() {
101 for (let i = 0; i < maxIterations; i++) {
102 const polled = yield* workflow.poll(executionId)
103 if (Option.isSome(polled) && polled.value._tag === "Complete") {
104 return polled.value
105 }
106 yield* Effect.sleep(step)
107 }
108 return undefined
109 })
110
111const runSuite = (engineLayer: Layer.Layer<WorkflowEngine.WorkflowEngine>) => {
112 const TestLayer = Handlers.pipe(

Callers 1

runSuiteFunction · 0.85

Calls 2

pollMethod · 0.65
sleepMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…