Go - NewSchedule()

Creates a new Schedule to run a function on a defined frequency.

import (
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
nitric.NewSchedule("aggregate-data").Every("3 days", func() {
fmt.Println("aggregating data")
})
nitric.Run()
}

Parameters

  • Name
    description
    Required
    Required
    Type
    string
    Description

    The unique name of this Schedule within the app. Subsequent calls to schedule with the same name will return the same object.

Notes

  • Schedules do not require access permissions to be specified.
  • During local development schedules can be triggered manually from the local development dashboard

Examples

Create a Schedule

import (
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
nitric.NewSchedule("send-reminder").Every("1 day", func() {
fmt.Println("sending data")
})
nitric.NewSchedule("archive-data").Cron("0 1 1 * *", func() {
fmt.Println("archiving data")
})
nitric.Run()
}
Last updated on Oct 11, 2024