feat(generation): migrate article generation and template-assist to RabbitMQ queues

Replace in-process generation with queue-based async execution via
RabbitMQ. Add generation task runtime for lifecycle management, article
generation payload/queue abstractions, and template-assist queue publisher.
Refactor prompt generation service to support batch generation with
per-item error tracking. Update stream hub to bridge queue events to SSE.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-15 14:20:26 +08:00
parent e8f48c6d37
commit ce13331e26
14 changed files with 951 additions and 173 deletions
@@ -219,7 +219,6 @@ func NewKnowledgeService(
go svc.runParseWorker()
}
go svc.recoverPendingParseTasks()
go svc.runDeletedCleanupWorker()
}
return svc
@@ -1753,17 +1752,6 @@ func (s *KnowledgeService) cleanupDeletedKnowledgeItemAsync(tenantID, itemID int
}()
}
func (s *KnowledgeService) runDeletedCleanupWorker() {
s.scheduleDeletedKnowledgeCleanup()
ticker := time.NewTicker(defaultKnowledgeCleanupPoll)
defer ticker.Stop()
for range ticker.C {
s.scheduleDeletedKnowledgeCleanup()
}
}
func (s *KnowledgeService) scheduleDeletedKnowledgeCleanup() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
@@ -1778,6 +1766,13 @@ func (s *KnowledgeService) scheduleDeletedKnowledgeCleanup() {
}
}
func (s *KnowledgeService) RunDeletedCleanupSweep() {
if s == nil {
return
}
s.scheduleDeletedKnowledgeCleanup()
}
func (s *KnowledgeService) listKnowledgeCleanupCandidates(
ctx context.Context,
limit int,