forked from goffee/cup
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:
parent
f4476d3e89
commit
3d051e9617
6 changed files with 203 additions and 0 deletions
31
config/scheduler.go
Normal file
31
config/scheduler.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) 2026 Jose Cely <me@jacs.guru>
|
||||
// Use of this source code is governed by MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.smarteching.com/goffee/core"
|
||||
)
|
||||
|
||||
// Retrieve the main config for the Simple Scheduler
|
||||
func GetSchedulerConfig() core.SchedulerConfig {
|
||||
//#####################################
|
||||
//# Main configuration for ####
|
||||
//# the Simple Scheduler (sche) ####
|
||||
//#####################################
|
||||
|
||||
return core.SchedulerConfig{
|
||||
// For enabling and disabling the simple scheduler system
|
||||
// set to true to enable it, set to false to disable
|
||||
EnableScheduler: false,
|
||||
|
||||
// How often the scheduler polls the database for new tasks
|
||||
SchedulerInterval: 10 * time.Second,
|
||||
|
||||
// Max tasks to process per tick (0 = unlimited)
|
||||
SchedulerRateLimit: 5,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue