Wires the scheduler into the cup application following the exact conventions of the Asynq queue integration. A new testmac/config/scheduler.go file provides GetSchedulerConfig() with enable flag, polling interval, and rate limit. A new testmac/register-scheduler.go file registers task handlers (send_email and flaky_task as samples) on the Schedulermux, creates the DB-backed store via core.ResolveGorm(), and launches the scheduler in a goroutine — only when EnableScheduler: true. The scheduler tables are migrated alongside other models in run-auto-migrations.go via db.AutoMigrate(&scheduler.QueueItem{}, &scheduler.ProcessedItem{}).

This commit is contained in:
Jose Cely 2026-06-13 18:59:06 -05:00
parent f4476d3e89
commit 3d051e9617
6 changed files with 203 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import (
"errors"
"git.smarteching.com/goffee/core"
"git.smarteching.com/goffee/core/scheduler"
"git.smarteching.com/goffee/cup/models"
"git.smarteching.com/goffee/cup/utils"
"gorm.io/gorm"
@ -26,6 +27,10 @@ func RunAutoMigrations() {
db.AutoMigrate(&models.RolePermission{})
db.AutoMigrate(&models.Permission{})
// Simple scheduler (sche) tables — enabled when scheduler is active
db.AutoMigrate(&scheduler.QueueItem{})
db.AutoMigrate(&scheduler.ProcessedItem{})
// End your auto migrations
// Create seed data data, DO NOT TOUCH