diff --git a/cmd/worker/main.go b/cmd/worker/main.go index 374ed0e..8ca9964 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -619,6 +619,21 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config, kbBindi } handlers["source.scan.pp"] = handler.Handle } + // 导入对账的作业处理器只依赖对账服务本身(租户 Key 走知识库绑定), + // 与旧测试库取件/上传链路(TEST_WEKNORA_ENABLED)无关,必须在下面那个 + // 早退之前注册;否则 RECONCILIATION_ENABLED=true 时候选只接线了 API, + // worker 从不认领 reconciliation.run,批次永远停在 running。 + if reconciliationService != nil { + handlers["reconciliation.run"] = func(handlerCtx context.Context, job jobs.Job) error { + var payload struct { + RunID string `json:"run_id"` + } + if err := json.Unmarshal(job.Payload, &payload); err != nil || payload.RunID == "" { + return jobs.Permanent(jobs.ErrCodeHandlerFallback, errors.New("invalid reconciliation run payload")) + } + return reconciliationService.ExecuteRun(handlerCtx, payload.RunID) + } + } if !config.TestWeKnoraEnabled || !config.LibraryWorkerRole.ExecutesSourceWork() { return handlers, nil } @@ -695,17 +710,6 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config, kbBindi handlers["test.poll"] = poll.Handle handlers["test.validate"] = validate.Handle handlers["test.remove"] = remove.Handle - if reconciliationService != nil { - handlers["reconciliation.run"] = func(handlerCtx context.Context, job jobs.Job) error { - var payload struct { - RunID string `json:"run_id"` - } - if err := json.Unmarshal(job.Payload, &payload); err != nil || payload.RunID == "" { - return jobs.Permanent(jobs.ErrCodeHandlerFallback, errors.New("invalid reconciliation run payload")) - } - return reconciliationService.ExecuteRun(handlerCtx, payload.RunID) - } - } return handlers, nil }