diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2025-01-05 16:39:13 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2025-01-05 16:39:13 -0800 |
commit | d25ec27fb1c3df175e1b98af1fdc26881d68a1ab (patch) | |
tree | a79c729b92c0d0a52b19b37c3a506b988f1e0b80 /scheduler/scheduler.go | |
download | whois-d25ec27fb1c3df175e1b98af1fdc26881d68a1ab.tar.gz whois-d25ec27fb1c3df175e1b98af1fdc26881d68a1ab.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..3c7c88d --- /dev/null +++ b/scheduler/scheduler.go @@ -0,0 +1,34 @@ +package scheduler + +import ( + "database/sql" + "log" + "time" + + "git.simponic.xyz/simponic/whois/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() +} |