Skip to content

Commit 975c63d

Browse files
ToriLindsayOxyjun
andauthored
Workflow example review (#19004)
* Workflow example review * Update src/content/docs/workflows/examples/backup-d1.mdx Co-authored-by: Jun Lee <[email protected]> --------- Co-authored-by: Jun Lee <[email protected]>
1 parent 8060450 commit 975c63d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/content/docs/workflows/examples/backup-d1.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ description: Send invoice when shopping cart is checked out and paid for
1717

1818
import { TabItem, Tabs } from "~/components"
1919

20-
In this example, we implement a Workflow periodically triggered by a [Cron Trigger](/workers/configuration/cron-triggers) to start a backup for a D1 database using the REST API and finally store the SQL dump in an [R2](/r2) bucket.
20+
In this example, we implement a Workflow periodically triggered by a [Cron Trigger](/workers/configuration/cron-triggers). That Workflow initiates a backup for a D1 database using the REST API, and then stores the SQL dump in an [R2](/r2) bucket.
2121

22-
Once a Workflow instance is triggered, fetches the REST API to start an export job for a specific database. Then, it fetches the same endpoint to check if the backup job is ready and the SQL dump is available to download.
22+
When the Workflow is triggered, it fetches the REST API to initiate an export job for a specific database. Then it fetches the same endpoint to check if the backup job is ready and the SQL dump is available to download.
2323

24-
As you can see, Workflows handles the responses and failures. It will retry the API calls until we get a successful response, retry fetching the backup from the URL provided, and retry saving the file to [R2](/r2). The developer doesn't have to care about any of that logic. The workflow can run until the backup file is ready, handling all the possible conditions until it is completed.
24+
As shown in this example, Workflows handles both the responses and failures, thereby removing the burden from the developer. Workflows retries the following steps:
2525

26-
This is a simplified example of backing up a [D1](/d1) database. For every step, we use the [default](/workflows/build/sleeping-and-retrying) sleeping and retrying configuration. In a real-life scenario, we would assume more steps and additional logic, but this example gives you a good idea of what you can do with Workflows.
26+
- API calls until it gets a successful response
27+
- Fetching the backup from the URL provided
28+
- Saving the file to [R2](/r2)
29+
30+
The Workflow can run until the backup file is ready, handling all of the possible conditions until it is completed.
31+
32+
This example provides simplified steps for backing up a [D1](/d1) database to help you understand the possibilities of Workflows. In every step, it uses the [default](/workflows/build/sleeping-and-retrying) sleeping and retrying configuration. In a real-world scenario, more steps and additional logic would likely be needed.
2733

2834
```ts
2935
import {
@@ -103,7 +109,7 @@ export default {
103109
};
104110
```
105111

106-
Here's a minimal package.json:
112+
Here is a minimal package.json:
107113

108114
```json
109115
{
@@ -114,7 +120,7 @@ Here's a minimal package.json:
114120
}
115121
```
116122

117-
And finally wrangler.toml:
123+
Here is a wrangler.toml:
118124

119125
import { WranglerConfig } from "~/components";
120126

0 commit comments

Comments
 (0)