fix: 保持当前页分块读取限流额度

This commit is contained in:
WuYongJie 2026-09-08 18:10:35 +08:00
parent 4fd134f636
commit ccd6fa9c99
2 changed files with 5 additions and 2 deletions

View File

@ -81,7 +81,7 @@ Content-Type: application/json
## 限流和超时
- 单账号数据库滚动窗口:服务全部账号 30 次/分钟、300 次/24 小时;同一人员 10 次/分钟;同一账号 5 次/分钟。当前页批次另按批次标记限制为服务 10 次/分钟、500 次/24 小时、同一人员 5 次/分钟;批次中的每个账号仍受同一账号 5 次/分钟限制。查看和复制共享账号额度,轮换令牌不重置服务身份或额度。
- 单账号数据库滚动窗口:服务全部账号 30 次/分钟、300 次/24 小时;同一人员 10 次/分钟;同一账号 5 次/分钟。公网 TLS 网关保留 1 KiB 敏感请求正文上限,财务端把 50 行当前页拆成两个最多 25 个账号的批次;批次标记因此按服务 20 次/分钟、1000 次/24 小时、同一人员 10 次/分钟限流,等价于原每页额度。批次中的每个账号仍受同一账号 5 次/分钟限制。查看和复制共享账号额度,轮换令牌不重置服务身份或额度。
- 已认证的成功、404、参数拒绝和解密失败均占额度;429 不延长窗口。额度检查与审计在同一数据库事务中用事务级锁串行化,跨进程/重启共享状态。
- 429 不携带剩余数量或精确窗口,避免推测其他用户行为。客户端不得自动重试密码读取;提示用户稍后再试,持续超限联系管理员。
- 财务客户端设置总超时 10 秒、禁用自动重定向和重试。后端池上限 4、连接获取 1 秒、SQL 执行 1.5 秒/客户端查询 2 秒、锁等待 1 秒,路由运行预算 10 秒。网关必须配置请求体 1 秒和总请求截止,防止慢请求占用。

View File

@ -15,7 +15,10 @@ export const revealVisiblePageInputSchema = z.object({
export const FINANCE_SERVICE_ID = 'finance-store-accounts'
export const VISIBLE_PAGE_ACCOUNT_ID = 'visible-page'
export const REVEAL_LIMITS = { serviceMinute: 30, serviceDay: 300, requesterMinute: 10, accountMinute: 5 } as const
export const VISIBLE_PAGE_LIMITS = { serviceMinute: 10, serviceDay: 500, requesterMinute: 5 } as const
// The public TLS gateway keeps request bodies below 1 KiB, so a 50-row page is
// sent as two 25-account chunks. These limits preserve the original per-page
// allowance after chunking while accountMinute still applies to every item.
export const VISIBLE_PAGE_LIMITS = { serviceMinute: 20, serviceDay: 1000, requesterMinute: 10 } as const
export type RevealInput = z.infer<typeof revealInputSchema>
export type RevealStatus = 200 | 403 | 404 | 429 | 503
export type RevealAudit = {