Go - Schedule.Every()
Sets the frequency and one or many handlers to be triggered.
import ("github.com/nitrictech/go-sdk/nitric")func main() {// Create a schedule that runs every 3 minutesnitric.NewSchedule("send reminder").Every("3 minutes", func() {// code which sends a reminder})nitric.Run()}
Parameters
- Name
rate
- Required
- Required
- Type
- string
- Description
The rate to run the schedule, e.g., '7 days'. All rates accept a number and a frequency. Valid frequencies are 'days', 'hours', or 'minutes'.
- Name
handler
- Required
- Required
- Type
- interface{}
- Description
The callback function to use as the handler which will run on the defined frequency.
Examples
Create a Schedule to run every 3 minutes
import ("github.com/nitrictech/go-sdk/nitric")func main() {// Create a schedule that runs every 3 minutesnitric.NewSchedule("send reminder").Every("3 minutes", func() {// code which sends a reminder})nitric.Run()}
Last updated on Oct 22, 2024