fix(task): restore task metadata contract and type fields in task types api

This commit is contained in:
ryan
2026-08-29 12:22:51 +08:00
parent 49f9d1076f
commit ea97b64407
22 changed files with 704 additions and 133 deletions
+15 -1
View File
@@ -171,9 +171,23 @@ func (p *Plugin) Apply(ctx *core.Context) error {
handler.RegisterRoutes(adminRouter)
// 2. Register Background Tasks
logSwitchHandler := &service.LogDBSwitchHandler{}
ctx.Task().Register(service.LogDBSwitchTask, func(c context.Context, payload []byte) error {
_, err := logSwitchHandler.Execute(c, payload)
return err
}, extpoints.WithTaskMeta(service.LogDBSwitchMeta))
ctx.Task().Register("admin:system_cleanup", func(_ context.Context, _ []byte) error {
return nil
}, extpoints.WithTaskRetry(1))
},
extpoints.WithTaskType("system_cleanup"),
extpoints.WithTaskName("系统垃圾清理"),
extpoints.WithTaskDescription("定期清理未使用上传文件、历史推送记录和过期任务执行日志"),
extpoints.WithTaskCategory("maintenance"),
extpoints.WithTaskRetry(1),
extpoints.WithTaskQueue("default"),
extpoints.WithTaskRetryable(true),
)
// 3. Register Cron Schedules
ctx.Schedule().RegisterCron("0 4 * * *", "admin:system_cleanup", map[string]string{"type": "daily"})