Function
waitForComplete
(
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). |
| 94 | const 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 | |
| 111 | const runSuite = (engineLayer: Layer.Layer<WorkflowEngine.WorkflowEngine>) => { |
| 112 | const TestLayer = Handlers.pipe( |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…