feat(task-queue): split upstream workers into isolated core/enrichment/maintenance pools

Route summary/sync/maintenance tasks to dedicated queues and servers so parsing, enrichment, and batch work no longer share one concurrency budget, while extending the runtime dashboard and settings validation to reflect the new topology.
This commit is contained in:
wizardchen
2026-07-10 23:19:41 +08:00
committed by lyingbug
parent fe47ac1f96
commit d496d0fc73
31 changed files with 847 additions and 290 deletions
+3 -1
View File
@@ -177,7 +177,9 @@ func (s *Scheduler) triggerSync(dataSourceID string, tenantID uint64) {
taskID := fmt.Sprintf("dssync:%s:%s", dataSourceID, time.Now().UTC().Truncate(time.Minute).Format("200601021504"))
_, err = s.taskEnqueuer.Enqueue(task,
asynq.Queue("low"),
asynq.Queue(types.QueueSync),
asynq.MaxRetry(5),
asynq.Timeout(2*time.Hour),
asynq.TaskID(taskID),
)
if err != nil {
+12 -1
View File
@@ -146,11 +146,19 @@ func (r *fakeSyncLogRepo) HasRunningSync(_ context.Context, dsID string) (bool,
// fakeTaskEnqueuer counts how many tasks are enqueued.
type fakeTaskEnqueuer struct {
count atomic.Int64
count atomic.Int64
lastQueue atomic.Value
}
func (e *fakeTaskEnqueuer) Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error) {
e.count.Add(1)
for _, opt := range opts {
if opt.Type() == asynq.QueueOpt {
if queue, ok := opt.Value().(string); ok {
e.lastQueue.Store(queue)
}
}
}
return &asynq.TaskInfo{ID: "task-fake"}, nil
}
@@ -210,6 +218,9 @@ func TestScheduler_CronFires(t *testing.T) {
if enqueuer.count.Load() == 0 {
t.Error("expected at least 1 enqueue, got 0")
}
if queue, _ := enqueuer.lastQueue.Load().(string); queue != types.QueueSync {
t.Errorf("scheduled sync queue = %q, want %q", queue, types.QueueSync)
}
}
func TestScheduler_AddOrUpdate(t *testing.T) {