When building backend applications you often need to run periodic and recurring tasks. For example, to send a welcome email to everyone who signed up recently. Encore provides native support for these types of use cases using Cron Jobs. Here's how easy it is:
import "encore.dev/cron"
// Send a welcome email to everyone who signed up in the last two hours.
var _ = cron.NewJob("welcome-email", cron.JobConfig{
Title: "Send welcome emails",
Every: 2 * cron.Hour,
Endpoint: SendWelcomeEmail,
})
That's it! When this is deployed, the Encore Platform will call the SendWelcomeEmail
endpoint (not pictured) every 2 hours. There is no need to maintain any infrastructure; Encore itself takes care of the scheduling, monitoring and execution. Hooray! ✨
What's more, Encore's web platform has a shiny new Cron Jobs dashboard to help you keep track of all your jobs. Check it out:
This means you can now schedule recurring tasks without worrying about:
- How yet another configuration language works –– it's just plain Go.
- Setting up and maintaining servers or third-party services –– it's all handled by Encore.
- Keeping track of what jobs are running in each environment – just check the dashboard!
To get started, install the latest Encore release with encore version update
and upgrade your application's dependency with go get encore.dev@latest
.
Check out the docs 📚 to learn more.
Bugfixes and other improvements
- Added support for code coverage with
encore test -cover
(#144) - Improved documentation on using external databases
- Improved documentation on handling database migration errors
- Improved documentation on how to use GCP (#102)
- Fixed
encore test
mistakenly requiring Docker when the app has no database (#98)
Thanks to @ValeriaVG and @wisdommatt for the contributions!