mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 07:36:37 +08:00
feat(openflare): 将定时任务迁入 Wavelet Asynq 异步任务框架
将 SSL 续期、可观测数据清理、WAF IP 组同步与 Uptime Kuma 同步 从 API 进程内 cron 迁移为 Asynq Handler,并通过 w_schedules 种子迁移 注册默认定时调度;移除 bootstrap 中的 in-process cron 启动逻辑。
This commit is contained in:
@@ -11,8 +11,6 @@ import (
|
||||
|
||||
admin_push "github.com/Rain-kl/Wavelet/internal/apps/admin/push"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/admin/push/custom_events"
|
||||
oftasks "github.com/Rain-kl/Wavelet/internal/apps/openflare/tasks"
|
||||
_ "github.com/Rain-kl/Wavelet/internal/apps/openflare/waf"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/risk_control"
|
||||
taskhandlers "github.com/Rain-kl/Wavelet/internal/task/handlers"
|
||||
"github.com/Rain-kl/Wavelet/pkg/logger"
|
||||
@@ -25,11 +23,10 @@ type Options struct {
|
||||
}
|
||||
|
||||
var (
|
||||
registerTasksOnce sync.Once
|
||||
registerPushDomainEventsOnce sync.Once
|
||||
registerTaskListenersOnce sync.Once
|
||||
registerOpenFlareBackgroundTasksOnce sync.Once
|
||||
initRuntimeOnce sync.Once
|
||||
registerTasksOnce sync.Once
|
||||
registerPushDomainEventsOnce sync.Once
|
||||
registerTaskListenersOnce sync.Once
|
||||
initRuntimeOnce sync.Once
|
||||
)
|
||||
|
||||
// RegisterTasks registers all built-in task handlers and metadata.
|
||||
@@ -53,16 +50,10 @@ func RegisterTaskListeners() {
|
||||
})
|
||||
}
|
||||
|
||||
// RegisterOpenFlareBackgroundTasks links OpenFlare in-process cron jobs registered via init().
|
||||
func RegisterOpenFlareBackgroundTasks() {
|
||||
registerOpenFlareBackgroundTasksOnce.Do(func() {})
|
||||
}
|
||||
|
||||
// RegisterAPI wires integrations required by the HTTP API process.
|
||||
func RegisterAPI() {
|
||||
RegisterTasks()
|
||||
RegisterPushDomainEvents()
|
||||
RegisterOpenFlareBackgroundTasks()
|
||||
}
|
||||
|
||||
// RegisterWorker wires integrations required by the task worker process.
|
||||
@@ -81,7 +72,6 @@ func RegisterAll() {
|
||||
RegisterTasks()
|
||||
RegisterPushDomainEvents()
|
||||
RegisterTaskListeners()
|
||||
RegisterOpenFlareBackgroundTasks()
|
||||
}
|
||||
|
||||
// Init runs shared runtime bootstrap exactly once per process.
|
||||
@@ -93,7 +83,6 @@ func Init(ctx context.Context, opts Options) {
|
||||
}
|
||||
if opts.API {
|
||||
risk_control.InitLogWriter(ctx)
|
||||
oftasks.Start(ctx)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -101,4 +90,4 @@ func Init(ctx context.Context, opts Options) {
|
||||
// ResetInitRuntimeOnceForTest clears initRuntimeOnce so Init can run again in unit tests.
|
||||
func ResetInitRuntimeOnceForTest() {
|
||||
initRuntimeOnce = sync.Once{}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user