避免联通实名回调因内部长度限制永久失效
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m9s

将实名事件身份收敛为受 Outbox 上限约束的稳定摘要,并允许相同 CUCC 回调原子认领失败终态后重试。

Constraint: 运营商回调固定返回成功,公共 Outbox event_id 上限为 64 字符

Rejected: 扩大数据库字段 | 根因是不受控事件 ID,且无法解决旧 failed 回调被吞

Confidence: high

Scope-risk: moderate

Directive: 新增稳定事件 ID 时必须服从持久化长度上限;失败回调恢复必须使用条件更新原子认领

Tested: gofmt;git diff --cached --check

Not-tested: 按用户要求未运行自动化测试、构建或测试环境重放
This commit is contained in:
2026-07-30 09:05:23 +08:00
parent c89291b362
commit 1141167598
5 changed files with 49 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ func (h *CUCCRealnameHandler) process(ctx context.Context, body []byte, contentT
return err
}
if !created {
claimed, claimErr := h.claimPending(ctx, log)
claimed, claimErr := h.claimRetryable(ctx, log)
if claimErr != nil || !claimed {
return claimErr
}
@@ -129,7 +129,7 @@ func (h *CUCCRealnameHandler) recordConflict(ctx context.Context, body []byte, c
return err
}
if !created {
claimed, claimErr := h.claimPending(ctx, log)
claimed, claimErr := h.claimRetryable(ctx, log)
if claimErr != nil || !claimed {
return claimErr
}
@@ -137,11 +137,18 @@ func (h *CUCCRealnameHandler) recordConflict(ctx context.Context, body []byte, c
return h.complete(ctx, log.IntegrationID, constants.IntegrationResultConflict, false, "同一实名语义对应不同载荷")
}
func (h *CUCCRealnameHandler) claimPending(ctx context.Context, log *model.IntegrationLog) (bool, error) {
if log == nil || log.Result != constants.IntegrationResultPending {
func (h *CUCCRealnameHandler) claimRetryable(ctx context.Context, log *model.IntegrationLog) (bool, error) {
if log == nil {
return false, nil
}
switch log.Result {
case constants.IntegrationResultPending:
return h.integration.ClaimExpiredInboundPending(ctx, log.IntegrationID, constants.IntegrationInboundProcessingLease)
case constants.IntegrationResultFailed:
return h.integration.ClaimFailedInbound(ctx, log.IntegrationID)
default:
return false, nil
}
return h.integration.ClaimExpiredInboundPending(ctx, log.IntegrationID, constants.IntegrationInboundProcessingLease)
}
func (h *CUCCRealnameHandler) complete(ctx context.Context, integrationID, result string, changed bool, reason string) error {