Skip to content

Commit 0f9932d

Browse files
authored
Merge branch 'production' into silverlock/workflows-fixes-1002am
2 parents deb08d0 + c337a95 commit 0f9932d

File tree

9 files changed

+53
-46
lines changed

9 files changed

+53
-46
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
/cloudflare-for-platforms/workers-for-platforms/ @irvinebroque @tanushree-sharma @angelampcosta @GregBrimble @cloudflare/pcx-technical-writing
132132
/src/content/docs/workers/observability/ @irvinebroque @mikenomitch @rohinlohe @cloudflare/pcx-technical-writing
133133
/src/content/docs/workers/static-assets @irvinebroque @tanushree-sharma @GregBrimble @WalshyDev @cloudflare/pcx-technical-writing
134+
/src/content/docs/workflows/ @elithrar @celso @sidharthachatterjee @cloudflare/pcx-technical-writing
134135

135136
# DDoS Protection
136137

src/content/docs/vectorize/platform/limits.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ sidebar:
77

88
The following limits apply to accounts, indexes and vectors (as specified):
99

10-
| Feature | Current Limit |
11-
| ------------------------------------------------------------- | ---------------------------------------------------------------- |
12-
| Indexes per account | 100 indexes |
13-
| Maximum dimensions per vector | 1536 dimensions |
14-
| Maximum vector ID length | 64 bytes |
15-
| Metadata per vector | 10KiB |
16-
| Maximum returned results (`topK`) with values or metadata | 20 |
17-
| Maximum returned results (`topK`) without values and metadata | 100 |
18-
| Maximum upsert batch size (per batch) | 1000 (Workers) / 5000 (HTTP API) |
19-
| Maximum index name length | 64 bytes |
20-
| Maximum vectors per index | 5,000,000 |
21-
| Maximum namespaces per index | 1000 namespaces |
22-
| Maximum namespace name length | 64 bytes |
23-
| Maximum vectors upload size | 100 MB |
24-
| Maximum metadata indexes per Vectorize index | 10 |
25-
| Maximum indexed data per metadata index per vector | 64 bytes |
10+
| Feature | Current Limit |
11+
| ------------------------------------------------------------- | ----------------------------------- |
12+
| Indexes per account | 50,000 (Workers Paid) / 100 (Free) |
13+
| Maximum dimensions per vector | 1536 dimensions |
14+
| Maximum vector ID length | 64 bytes |
15+
| Metadata per vector | 10KiB |
16+
| Maximum returned results (`topK`) with values or metadata | 20 |
17+
| Maximum returned results (`topK`) without values and metadata | 100 |
18+
| Maximum upsert batch size (per batch) | 1000 (Workers) / 5000 (HTTP API) |
19+
| Maximum index name length | 64 bytes |
20+
| Maximum vectors per index | 5,000,000 |
21+
| Maximum namespaces per index | 50,000 (Workers Paid) / 1000 (Free) |
22+
| Maximum namespace name length | 64 bytes |
23+
| Maximum vectors upload size | 100 MB |
24+
| Maximum metadata indexes per Vectorize index | 10 |
25+
| Maximum indexed data per metadata index per vector | 64 bytes |
2626

2727
## Limits V1 (deprecated)
2828

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,23 @@ Store state durably by returning it from your `step.do` callbacks.
2929

3030
```ts
3131
export default {
32-
async fetch(req: Request, env: Env) {
33-
let someEvent = { url: req.url, createdTimestamp: Date.now() }
34-
// Trigger our Workflow
35-
// Pass our event as the second parameter to the `create` method
36-
// on our Workflow binding.
37-
let instance = await env.MYWORKFLOW.create(await crypto.randomUUID(), someEvent);
38-
39-
return Response.json({
40-
id: instance.id,
41-
details: await instance.status(),
42-
});
43-
44-
return Response.json({ result });
45-
},
32+
async fetch(req: Request, env: Env) {
33+
let someEvent = { url: req.url, createdTimestamp: Date.now() }
34+
// Trigger our Workflow
35+
// Pass our event as the second parameter to the `create` method
36+
// on our Workflow binding.
37+
let instance = await env.MYWORKFLOW.create({
38+
id: await crypto.randomUUID(),
39+
params: someEvent
40+
});
41+
42+
return Response.json({
43+
id: instance.id,
44+
details: await instance.status(),
45+
});
46+
47+
return Response.json({ result });
48+
},
4649
};
4750
```
4851

src/content/docs/workflows/build/rules-of-workflows.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ check if they were already charged:
1919

2020
```ts
2121
export class MyWorkflow extends WorkflowEntrypoint {
22-
async run(event: WorkflowEvent, step: WorkflowStep) {
22+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
2323
const customer_id = 123456;
2424
// ✅ Good: Non-idempotent API/Binding calls are always done **after** checking if the operation is
2525
// still needed.
@@ -69,7 +69,7 @@ You can also think of it as a transaction, or a unit of work.
6969

7070
```ts
7171
export class MyWorkflow extends WorkflowEntrypoint {
72-
async run(event: WorkflowEvent, step: WorkflowStep) {
72+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
7373
// ✅ Good: Unrelated API/Binding calls are self-contained, so that in case one of them fails
7474
// it can retry them individually. It also has an extra advantage: you can control retry or
7575
// timeout policies for each granular step - you might not to want to overload http.cat in
@@ -94,7 +94,7 @@ Otherwise, your entire Workflow might not be as durable as you might think, and
9494

9595
```ts
9696
export class MyWorkflow extends WorkflowEntrypoint {
97-
async run(event: WorkflowEvent, step: WorkflowStep) {
97+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
9898
// 🔴 Bad: you're calling two seperate services from within the same step. This might cause
9999
// some extra calls to the first service in case the second one fails, and in some cases, makes
100100
// the step non-idempotent altogether
@@ -120,7 +120,7 @@ function getRandomInt(min, max) {
120120
}
121121

122122
export class MyWorkflow extends WorkflowEntrypoint {
123-
async run(event: WorkflowEvent, step: WorkflowStep) {
123+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
124124
// 🔴 Bad: `imageList` will be not persisted across engine's lifetimes. Which means that after hibernation,
125125
// `imageList` will be empty again, even though the following two steps have already ran.
126126
const imageList: string[] = [];
@@ -163,7 +163,7 @@ function getRandomInt(min, max) {
163163
}
164164

165165
export class MyWorkflow extends WorkflowEntrypoint {
166-
async run(event: WorkflowEvent, step: WorkflowStep) {
166+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
167167
// ✅ Good: imageList state is exclusively comprised of step returns - this means that in the event of
168168
// multiple engine lifetimes, imageList will be built accordingly
169169
const imageList: string[] = await Promise.all([
@@ -231,7 +231,7 @@ Dynamically naming a step will prevent it from being cached, and cause the step
231231
232232
```ts
233233
export class MyWorkflow extends WorkflowEntrypoint {
234-
async run(event: WorkflowEvent, step: WorkflowStep) {
234+
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
235235
// 🔴 Bad: Dynamically naming the step prevents it from being cached
236236
// This will cause the step to be re-run if subsequent steps fail.
237237
await step.do(`step #1 running at: ${Date.now}`, async () => {

src/content/docs/workflows/build/sleeping-and-retrying.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ This can be useful when you detect a terminal (permanent) error from an upstream
9595
9696
```ts
9797
// Import the NonRetryableError definition
98-
import { WorkflowEntrypoint, WorkflowStep, WorkflowEvent, NonRetryableError } from 'cloudflare:workers';
98+
import { WorkflowEntrypoint, WorkflowStep, WorkflowEvent } from 'cloudflare:workers';
99+
import { NonRetryableError } from 'cloudflare:workflows';
99100
100101
// In your step code:
101102
export class MyWorkflow extends WorkflowEntrypoint<Env, Params> {

src/content/docs/workflows/build/trigger-workflows.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To bind to a Workflow from your Workers code, you need to define a [binding](/wo
3434
```toml title="wrangler.toml"
3535
name = "workflows-tutorial"
3636
main = "src/index.ts"
37-
compatibility_date = "2024-10-15"
37+
compatibility_date = "2024-10-22"
3838

3939
[[workflows]]
4040
# The name of the Workflow
@@ -80,7 +80,7 @@ export default {
8080
// Else, create a new instance of our Workflow, passing in any (optional) params
8181
// and return the ID.
8282
const newId = await crypto.randomUUID();
83-
let instance = await env.MY_WORKFLOW.create(newId, {});
83+
let instance = await env.MY_WORKFLOW.create({ id: newId });
8484
return Response.json({
8585
id: instance.id,
8686
details: await instance.status(),

src/content/docs/workflows/build/workers-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ For example, to bind to a Workflow called `workflows-starter` and to make it ava
111111
#:schema node_modules/wrangler/config-schema.json
112112
name = "workflows-starter"
113113
main = "src/index.ts"
114-
compatibility_date = "2024-10-16"
114+
compatibility_date = "2024-10-22"
115115

116116
[[workflows]]
117117
# name of your workflow

src/content/docs/workflows/get-started/cli-quick-start.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ You can run a Workflow via the `wrangler` CLI, via a Worker binding, or via the
161161

162162
```sh
163163
# Trigger a Workflow from the CLI, and pass (optional) parameters as an event to the Workflow.
164-
npx wrangler@latest workflows trigger workflows-tutorial --params={"hello":"world"}
164+
npx wrangler@latest workflows trigger workflows-tutorial --params={"email": "[email protected]", "metadata": {"id": "1"}}
165165
```
166166

167167
Refer to the [events and parameters documentation](/workflows/build/events-and-parameters/) to understand how events are passed to Workflows.

src/content/docs/workflows/get-started/guide.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ At its most basic, a step looks like this:
136136
// Import the Workflow definition
137137
import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from "cloudflare:workers"
138138

139+
type Params = {}
140+
139141
// Create your own class that implements a Workflow
140142
export class MyWorkflow extends WorkflowEntrypoint<Env, Params> {
141143
// Define a run() method
@@ -162,9 +164,9 @@ When trying to decide whether to break code up into more than one step, a good r
162164

163165
For example, each of the below tasks is ideally encapsulated in its own step, so that any failure — such as a file not existing, a third-party API being down or rate limited — does not cause your entire program to fail.
164166

165-
* Reading or writing files from R2
167+
* Reading or writing files from [R2](/r2/)
166168
* Running an AI task using [Workers AI](/workers-ai/)
167-
* Querying a D1 database or a database via [Hyperdrive](/hyperdrive/)
169+
* Querying a [D1 database](/d1/) or a database via [Hyperdrive](/hyperdrive/)
168170
* Calling a third-party API
169171

170172
If a subsequent step fails, your Workflow can retry from that step, using any state returned from a previous step. This can also help you avoid unnecessarily querying a database or calling an paid API repeatedly for data you have already fetched.
@@ -187,7 +189,7 @@ Open the `wrangler.toml` file at the root of your `workflows-starter` folder, wh
187189
#:schema node_modules/wrangler/config-schema.json
188190
name = "workflows-starter"
189191
main = "src/index.ts"
190-
compatibility_date = "2024-10-23"
192+
compatibility_date = "2024-10-22"
191193

192194
[[workflows]]
193195
# name of your workflow
@@ -196,7 +198,7 @@ name = "workflows-starter"
196198
binding = "MY_WORKFLOW"
197199
# this is class that extends the Workflow class in src/index.ts
198200
class_name = "MyWorkflow"
199-
# script_name is required during for the beta.
201+
# script_name is required during the beta.
200202
# Must match the "name" of your Worker at the top of wrangler.toml
201203
script_name = "workflows-starter"
202204
```
@@ -374,7 +376,7 @@ Your worker has access to the following bindings:
374376
- MY_WORKFLOW: MyWorkflow (defined in workflows-starter)
375377
Uploaded workflows-starter (2.53 sec)
376378
Deployed workflows-starter triggers (1.12 sec)
377-
https://workflows-starter.silverlock.workers.dev
379+
https://workflows-starter.YOUR_WORKERS_SUBDOMAIN.workers.dev
378380
workflow: workflows-starter
379381
```
380382

0 commit comments

Comments
 (0)