#[non_exhaustive]pub enum PushDropReason {
ScopeMissing,
QuoteScope,
TradeScope,
BroadcastScope,
TradeAccIdMismatch,
TradeMarketMismatch,
NotifyNotSubscribed,
TradeDecodeFailed,
}Expand description
v1.4.106 codex 0542 F4 [P3]: WS push drop 原因 closed-set enum (8 variants).
把 4 surface (REST /ws / gRPC subscribe / raw TCP WS / MCP push) 散在
各自代码里的 bump_ws_filtered("foo", ...) 字符串 label 收口为闭合 enum,
防漂移. 任何新增 drop 原因必须在 enum 加 variant, 否则 caller 编译期
不通过 — 强制同步 dashboard label.
与 v1.4.105 之前的 event.event_type.as_str() 自由字符串方案相比:
- Closed set: enum match 编译期穷举, 不会有 typo
trade_market→trade_marketesilent drop dashboard. - 统一命名: 跨 surface 同 reason 必同一 label (REST
trade_market== gRPCtrade_market== MCPtrade_market, 不再各自 emit “trade” / “trade_acc_id” 混淆 dashboard aggregation). - Future-safe: 加新 reason 时 grep
PushDropReason::找全所有 caller, 不漏 surface.
8 variants 设计依据 (v1.4.106 ship 时):
| variant | label | 触发场景 |
|---|---|---|
ScopeMissing | scope | client 持 scope 不含 event 需要的 (e.g. event 是 trade push 但 client 仅 qot:read) |
QuoteScope | quote | quote push scope 不满足 (legacy event_type label 兼容) |
TradeScope | trade | trade push scope 不满足 (legacy 兼容) |
BroadcastScope | broadcast | broadcast push scope 不满足 (legacy 兼容) |
TradeAccIdMismatch | trade_acc_id | trade push event.acc_id ∉ key.allowed_acc_ids |
TradeMarketMismatch | trade_market | trade push event.trd_market ∉ key.allowed_markets |
NotifyNotSubscribed | notify_unsub | broadcast/notify push 但 client 未显式 sub (IsConnSubRecvNotify) |
TradeDecodeFailed | trade_decode_failed | trade push body decode 失败, 防御性 drop |
as_metric_label() 返定 &'static str 与历史 dashboard label byte-identical
(向后兼容).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ScopeMissing
通用 scope 不满足 (新加 — 替代各 surface 自定义 event_type label).
QuoteScope
Quote push scope 不满足 (legacy event_type=quote label 兼容).
TradeScope
Trade push scope 不满足 (legacy event_type=trade label 兼容).
BroadcastScope
Broadcast push scope 不满足 (legacy event_type=broadcast label 兼容).
TradeAccIdMismatch
Layer 1 — trade push event.acc_id ∉ key.allowed_acc_ids.
TradeMarketMismatch
Layer 3 — trade push event.trd_market ∉ key.allowed_markets.
NotifyNotSubscribed
notify_subscribe gate (IsConnSubRecvNotify) 未启用.
TradeDecodeFailed
Trade push body decode 失败 — 防御性 drop, 防 backend wire 错误推不可解的 push.
Implementations§
Source§impl PushDropReason
impl PushDropReason
Sourcepub fn as_metric_label(&self) -> &'static str
pub fn as_metric_label(&self) -> &'static str
Prometheus reason= label 字符串 (8 固定桶).
Sourcepub fn from_legacy_event_type(s: &str) -> Self
pub fn from_legacy_event_type(s: &str) -> Self
v1.4.106 codex 0542 F4 [P3]: 从 v1.4.105 之前的 event_type 字符串
兼容 helper. 让 surface migration 渐进 (旧 event.event_type 字符串
走这个 fn 转 typed). 未识别字符串 → ScopeMissing (向后兼容默认).
用法: PushDropReason::from_legacy_event_type(&event.event_type).
Trait Implementations§
Source§impl Clone for PushDropReason
impl Clone for PushDropReason
Source§fn clone(&self) -> PushDropReason
fn clone(&self) -> PushDropReason
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more