diff options
author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-01-12 23:09:34 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-01-12 23:09:34 -0800 |
commit | 18a945aab9b3129b82076f633fab1d13ba28148e (patch) | |
tree | 09703cdc24992c42c5c14051e73e0b614280f5bd /scheduler/scheduler.go | |
download | phoneassistant-18a945aab9b3129b82076f633fab1d13ba28148e.tar.gz phoneassistant-18a945aab9b3129b82076f633fab1d13ba28148e.zip |
initial commit by simponic-infra
Diffstat (limited to 'scheduler/scheduler.go')
-rw-r--r-- | scheduler/scheduler.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go new file mode 100644 index 0000000..106b28b --- /dev/null +++ b/scheduler/scheduler.go @@ -0,0 +1,34 @@ +package scheduler + +import ( + "database/sql" + "log" + "time" + + "git.simponic.xyz/simponic/phoneassistant/args" + "github.com/go-co-op/gocron/v2" +) + +func StartScheduler(_dbConn *sql.DB, argv *args.Arguments) { + scheduler, err := gocron.NewScheduler() + if err != nil { + panic("could not create scheduler") + } + + _, err = scheduler.NewJob( + gocron.DurationJob( + 24*time.Hour, + ), + gocron.NewTask( + func(msg string) { + log.Println(msg) + }, + "it's a beautiful new day!", + ), + ) + if err != nil { + panic("could not create job") + } + + scheduler.Start() +} |