refactor: clean code

This commit is contained in:
Fu Diwei
2024-12-23 19:31:48 +08:00
parent d509445519
commit 9ef16ebcf9
6 changed files with 21 additions and 9 deletions

24
internal/app/scheduler.go Normal file
View File

@@ -0,0 +1,24 @@
package app
import (
"sync"
"time"
"github.com/pocketbase/pocketbase/tools/cron"
)
var scheduler *cron.Cron
var schedulerOnce sync.Once
func GetScheduler() *cron.Cron {
schedulerOnce.Do(func() {
scheduler = cron.New()
location, err := time.LoadLocation("Local")
if err == nil {
scheduler.SetTimezone(location)
}
})
return scheduler
}