fix(调度): 修复 outbox 空载写入并稳固回放测试

将 outbox payload 为空时写入 NULL
避免事务因 JSON 解析错误中断
调整回放测试为预置缓存后验证 last_used 更新

测试: go test -tags=integration ./internal/repository
This commit is contained in:
yangjianbo
2026-01-12 15:46:55 +08:00
parent 8c1958c9ad
commit 9622347faa
2 changed files with 4 additions and 17 deletions

View File

@@ -80,17 +80,17 @@ func enqueueSchedulerOutbox(ctx context.Context, exec sqlExecutor, eventType str
if exec == nil {
return nil
}
var payloadJSON []byte
var payloadArg any
if payload != nil {
encoded, err := json.Marshal(payload)
if err != nil {
return err
}
payloadJSON = encoded
payloadArg = encoded
}
_, err := exec.ExecContext(ctx, `
INSERT INTO scheduler_outbox (event_type, account_id, group_id, payload)
VALUES ($1, $2, $3, $4)
`, eventType, accountID, groupID, payloadJSON)
`, eventType, accountID, groupID, payloadArg)
return err
}