Merge pull request 'fix(reconciliation): worker 在对账接线时注册 reconciliation.run(CYWL-34)' (#49) from fix/t6-worker-handler-gate into main
build / build (push) Successful in 2m3s

Merge pull request 'fix(reconciliation): worker 在对账接线时注册 reconciliation.run(CYWL-34)' (#49) from fix/t6-worker-handler-gate into main
This commit was merged in pull request #49.
This commit is contained in:
2026-12-01 20:15:25 +08:00
+15 -11
View File
@@ -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
}