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

Function waitForSuspended

packages/infra/test/cluster-sqlite.test.ts:159–176  ·  view source on GitHub ↗
(
  workflow: {
    readonly poll: (
      executionId: string
    ) => Effect.Effect<Option.Option<Workflow.Result<A, E>>, never, R>
  },
  executionId: string
)

Source from the content-addressed store, hash-verified

157
158const waitForSequentialWorkflowSuspended = (executionId: string) =>
159 waitForSuspended(SequentialDeferredWorkflow, executionId)
160
161const waitForSuspended = <A, E, R>(
162 workflow: {
163 readonly poll: (
164 executionId: string
165 ) => Effect.Effect<Option.Option<Workflow.Result<A, E>>, never, R>
166 },
167 executionId: string
168) =>
169 Effect.gen(function*() {
170 const sharding = yield* Sharding.Sharding
171 for (let i = 0; i < 100; i++) {
172 yield* sharding.pollStorage
173 const polled = yield* workflow.poll(executionId)
174 if (Option.isSome(polled) && polled.value._tag === "Suspended") return
175 yield* Effect.sleep(Duration.millis(100))
176 }
177 return yield* Effect.fail(new Error(`Workflow ${executionId} did not suspend`))
178 })
179

Calls 3

pollMethod · 0.65
sleepMethod · 0.65
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…