Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions email-sender/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ add OPENAI_API_KEY, SENDGRID_API_KEY, FROM_EMAIL, TO_EMAIL in .env

```bash
npm i
npm build
npm dev
npm run build
npm run dev
```

Your code will be running and syncing with Restack engine to execute workflows or functions.
Expand All @@ -55,4 +55,4 @@ In another shell:
npm run schedule-retries
```

Will schedule to start example workflow immediately. The code for this is on `scheduleWorkflowRetries.ts`. In here you can see how the sendEmailWorkflow is scheduled to be exectuted and the step to generate email content is force to have a failure and show how Restack will handle retries automatically for you. Step will fail once and be successfull on the next retry, then rest of steps defined on workflow will be exectuted correctly
This will schedule the example workflow to start immediately. The code for this is in `scheduleWorkflowRetries.ts`. In this file, you can see how the `sendEmailWorkflow` is scheduled for execution. The step to generate email content is intentionally set to fail once, demonstrating how Restack automatically handles retries. After the first failure, the step will succeed on the next retry, and the remaining steps in the workflow will execute as expected.
2 changes: 2 additions & 0 deletions email-sender/src/functions/sendEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ export async function sendEmail({ text, subject, to }: EmailInput) {
} catch (error) {
throw FunctionFailure.nonRetryable('Failed to send email');
}

return 'Email sent successfully';
}
1 change: 1 addition & 0 deletions email-sender/src/workflows/sendEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export async function sendEmailWorkflow({
});

log.info('Email sent successfully');
return 'Email sent successfully';
}