feat(infra): add scheduler and worker-generate standalone processes

Extract monitoring recovery/inspection workers and schedule dispatch
into a dedicated scheduler process. Add worker-generate process for
article generation and template-assist queue consumption. Introduce
shared/schedule runtime for cron-based worker lifecycle management.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-15 14:19:21 +08:00
parent b46cfaaa61
commit 3f5b5c1e01
11 changed files with 1588 additions and 1 deletions
@@ -0,0 +1,43 @@
package scheduler
import (
"context"
"time"
tenantapp "github.com/geo-platform/tenant-api/internal/tenant/app"
)
type KnowledgeDeletedCleanupWorker struct {
service *tenantapp.KnowledgeService
interval time.Duration
}
func NewKnowledgeDeletedCleanupWorker(service *tenantapp.KnowledgeService) *KnowledgeDeletedCleanupWorker {
return &KnowledgeDeletedCleanupWorker{
service: service,
interval: 15 * time.Second,
}
}
func (w *KnowledgeDeletedCleanupWorker) Start(ctx context.Context) {
if w == nil || w.service == nil {
return
}
go w.run(ctx)
}
func (w *KnowledgeDeletedCleanupWorker) run(ctx context.Context) {
w.service.RunDeletedCleanupSweep()
ticker := time.NewTicker(w.interval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
w.service.RunDeletedCleanupSweep()
}
}
}