Skip to content

Commit eb20532

Browse files
committed
changelog done
1 parent cf2a3c8 commit eb20532

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/content/changelog/workflows/2025-04-07-workflows-ga.mdx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Render, PackageManagers, TypeScriptExample } from "~/components"
1212
[Workflows](/workflows/) is now _Generally Available_ (or "GA"): in short, it's ready for production workloads. Alongside marking Workflows as GA, we've introduced a number of changes during the beta period, including:
1313

1414
* A new `waitForEvent` API that allows a Workflow to wait for an event to occur before continuing execution.
15-
* Increased concurrency: you can [run up to 4,500 Workflow instances](/changelog/2025-02-25-workflows-concurrency-increased/) concurrently (and this will continue to grow)
15+
* Increased concurrency: you can [run up to 4,500 Workflow instances](/changelog/2025-02-25-workflows-concurrency-increased/) concurrently and this will continue to grow.
1616
* Improved observability, including new CPU time metrics that allow you to better understand which Workflow instances are consuming the most resources and/or contributing to your bill.
1717
* Support for `vitest` for testing Workflows locally and in CI/CD pipelines.
1818

@@ -31,7 +31,37 @@ For example, if you wanted to implement a human-in-the-loop approval process, yo
3131
```ts
3232
import { Workflow, WorkflowEvent } from "cloudflare:workflows";
3333

34+
export class MyWorkflow extends WorkflowEntrypoint<Env, Params> {
35+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
36+
// Other steps in your Workflow
37+
let event = await step.waitForEvent<IncomingStripeWebhook>("receive invoice paid webhook from Stripe", { type: "stripe-webhook", timeout: "1 hour" })
38+
// Rest of your Workflow
39+
}
40+
}
41+
```
42+
43+
</TypeScriptExample>
44+
45+
You can then send a Workflow an event from an external service via HTTP or from within a Worker using the [Workers API](/workflows/build/workers-api/) for Workflows:
46+
47+
<TypeScriptExample>
48+
49+
```ts
50+
export default {
51+
async fetch(req: Request, env: Env) {
52+
const instanceId = new URL(req.url).searchParams.get("instanceId")
53+
const webhookPayload = await req.json<Payload>()
54+
55+
let instance = await env.MY_WORKFLOW.get(instanceId);
56+
// Send our event, with `type` matching the event type defined in
57+
// our step.waitForEvent call
58+
await instance.sendEvent({type: "stripe-webhook", payload: webhookPayload})
3459

60+
return Response.json({
61+
status: await instance.status(),
62+
});
63+
},
64+
};
3565
```
3666

3767
</TypeScriptExample>

src/content/docs/workflows/build/events-and-parameters.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You can pass parameters to a Workflow in three ways:
1818

1919
* As an optional argument to the `create` method on a [Workflow binding](/workers/wrangler/commands/#trigger) when triggering a Workflow from a Worker.
2020
* Via the `--params` flag when using the `wrangler` CLI to trigger a Workflow.
21-
* Via the `step.waitForEvent` API, which allows a Workflow instance to wait for an event (and optional data) to be received _while it is running_.
21+
* Via the `step.waitForEvent` API, which allows a Workflow instance to wait for an event (and optional data) to be received _while it is running_. Workflow instances can be sent events from external services over HTTP or via the Workers API for Workflows.
2222

2323
You can pass any JSON-serializable object as a parameter.
2424

0 commit comments

Comments
 (0)