Restate Typescript SDK
    Preparing search index...
    • Run a generator-based workflow against a Restate context.

      op is an Operation<T> — typically the result of gen(function*() { ... }). Inside the generator body, reach for the free-standing API (run, sleep, all, state, …) imported from @restatedev/restate-sdk-gen. They read the active scheduler from a synchronous current-fiber slot installed by Fiber.advance.

      gen() already takes a factory, so the same Operation is re- iterable across multiple execute() calls — no need for a builder lambda at this boundary.

      By default execute resolves as soon as the main operation settles; spawned fibers (and race losers) still running at that point are abandoned. Pass { onMainExit: "join" } to instead keep driving until every spawned fiber has finished.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

      execute(ctx, gen(function* () {
      const greeting = yield* run(async () => "hi", { name: "compose" });
      return greeting;
      }));