From 478f9e0614a6fe35d094aee611c708fdcc0cf798 Mon Sep 17 00:00:00 2001 From: ToriLindsay Date: Fri, 3 Jan 2025 15:50:18 +0000 Subject: [PATCH 1/2] Workflow example review --- src/content/docs/workflows/examples/backup-d1.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/content/docs/workflows/examples/backup-d1.mdx b/src/content/docs/workflows/examples/backup-d1.mdx index 59784f51416cfd0..4ad8eb14e1396eb 100644 --- a/src/content/docs/workflows/examples/backup-d1.mdx +++ b/src/content/docs/workflows/examples/backup-d1.mdx @@ -17,13 +17,13 @@ description: Send invoice when shopping cart is checked out and paid for import { TabItem, Tabs } from "~/components" -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. +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. -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. +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. -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. +As shown in this example, Workflows handles both the responses and failures, so the developer does not have to. Workflows retries the API calls until it gets a successful response, retries fetching the backup from the URL provided, and then retries saving the file to [R2](/r2). The workflow can run until the backup file is ready, handling all of the possible conditions until it is completed. -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. +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. ```ts import { @@ -103,7 +103,7 @@ export default { }; ``` -Here's a minimal package.json: +Here is a minimal package.json: ```json { @@ -114,7 +114,7 @@ Here's a minimal package.json: } ``` -And finally wrangler.toml: +Here is a wrangler.toml: import { WranglerConfig } from "~/components"; From f4829b1a5a28ae08187bc42fb165ea8689f40de6 Mon Sep 17 00:00:00 2001 From: ToriLindsay Date: Mon, 6 Jan 2025 09:38:54 +0000 Subject: [PATCH 2/2] Update src/content/docs/workflows/examples/backup-d1.mdx Co-authored-by: Jun Lee --- src/content/docs/workflows/examples/backup-d1.mdx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/content/docs/workflows/examples/backup-d1.mdx b/src/content/docs/workflows/examples/backup-d1.mdx index 4ad8eb14e1396eb..f951a84bcf3b4c5 100644 --- a/src/content/docs/workflows/examples/backup-d1.mdx +++ b/src/content/docs/workflows/examples/backup-d1.mdx @@ -21,7 +21,13 @@ In this example, we implement a Workflow periodically triggered by a [Cron Trigg 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. -As shown in this example, Workflows handles both the responses and failures, so the developer does not have to. Workflows retries the API calls until it gets a successful response, retries fetching the backup from the URL provided, and then retries saving the file to [R2](/r2). The workflow can run until the backup file is ready, handling all of the possible conditions until it is completed. +As shown in this example, Workflows handles both the responses and failures, thereby removing the burden from the developer. Workflows retries the following steps: + +- API calls until it gets a successful response +- Fetching the backup from the URL provided +- Saving the file to [R2](/r2) + +The Workflow can run until the backup file is ready, handling all of the possible conditions until it is completed. 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.