-
Notifications
You must be signed in to change notification settings - Fork 448
核心设计解析
Eric Zhao edited this page Jul 27, 2020
·
5 revisions
-
StatPrepareSlot:处于整个 chain 最开始的部分,用于初始化一些必要的统计结构。执行方式为顺序执行,不应出现异常。 -
RuleCheckingSlot:用于规则检查,执行方式为顺序执行,规则检查的状态包装在返回值内TokenResult。若返回状态不为 Blocked 则继续执行,若为 Blocked 则中断执行并返回 Blocked。 -
StatSlot:根据规则检查的结果,更新统计数据并做一些额外的记录(如记录日志、将事件透传给外部)。StatSlot 包含三个函数:OnEntryPassed、OnEntryBlocked和OnCompleted。
Slot 的每次 Entry 传递当前的 EntryContext
TokenResult 由每个 RuleCheckingSlot 返回,指示控制行为:
-
ResultStatusPass: 当前 slot 允许通过,可以执行后续的 slot -
ResultStatusBlocked: 当前 slot 拒绝通过,中断 slot 执行 -
ResultStatusShouldWait: 当前 slot 允许通过,但须等待一段时间
BlockError 代表该调用被 Sentinel 拒绝,可通过 BlockType 获取规则触发类型。
-
文档
-
Documents (EN)