知识卡片
用户配额可按需补充令牌
按用户维护令牌桶时,可根据距上次补充的经过时间计算新增令牌,不必为每个用户开常驻定时器。超额是正常业务拒绝而非内部错误;返回的布尔值宜表达“动作已执行”或“获准”,与错误结果分开。原稿注释与部分文字将true含义写反,应按实际执行分支理解。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Resilience · 查看原书依据
it refills buckets on demand, based on the time elapsed between requests. This strategy means that we don’t have to dedicate background processes to filling buckets until they’re actually used, which will scale much more effectively. // Effector is the function that you want to subject to throttling. type Effector func(context.Context) (string, error) // Throttled
参考来源
- 位置:《Cloud Native Go》第09章《Resilience》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch09.xhtml)
- 结论依据:按用户维护令牌桶时,可根据距上次补充的经过时间计算新增令牌,不必为每个用户开常驻定时器。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:it refills buckets on demand, based on the time elapsed between requests. This strategy means that we don’t have to dedicate background processes to filling buckets until they’re actually used, which will scale much more effectively. // Effector is the function that you want to subject to throttling. type Effector func(context.Context) (string, error) // Throttled