Skip to main content

PushSubscriber

Struct PushSubscriber 

Source
pub struct PushSubscriber {
    pub peer: Peer<RoleServer>,
    pub acc_ids: HashSet<u64>,
    pub allowed_acc_ids_snapshot: Option<HashSet<u64>>,
    pub allowed_markets_snapshot: Option<HashSet<String>>,
    pub registered_at: Instant,
    pub owner_key_id: Option<String>,
}
Expand description

v1.4.38 Phase 5: 订阅了 push 通知的 MCP 客户端 session 记录。

每个 session 用 futu_sub_acc_push 注册时登记一条。daemon push 事件来到 MCP server 时,按 acc_ids 过滤后用 peer.notify_logging_message() 推回。

v1.4.38 100%:acc_ids 过滤已生效(state.rs drain loop 实装)。 caller key ownership / scope 快照在注册时解析并保存,后续 push 分发不再 重新读取 bearer 明文。

Fields§

§peer: Peer<RoleServer>

rmcp 对 MCP session 的抽象。clone 便宜(内部 Arc)。

§acc_ids: HashSet<u64>

该 session 关心的 acc_id 列表。空集合表示“不过滤“(接收所有 acc 的 push)。

§allowed_acc_ids_snapshot: Option<HashSet<u64>>

v1.4.39 per-key acc_id 白名单注册时快照(非 live-reload)。

Some(set) + non-empty → push 的 acc_id 必须在 set 里才推。 Some(empty) / None → 不做 key 级过滤(兼容无 allowed_acc_ids 约束的 key 或 stdio / legacy 模式)。

快照语义:注册后 SIGHUP 重载 keys.json 修改 allowed_acc_ids 不会立即 反映到已注册订阅者。用户需重新 futu_sub_acc_push 才应用新 scope。 这是 defense-in-depth 层(主 auth 在 tool 调用时 guard.rs),可接受。

§allowed_markets_snapshot: Option<HashSet<String>>

v1.4.105 T-C2: per-key allowed_markets 注册时快照, Layer 3 trade push gate.

Some(set) + non-empty → push event 的 trd_market 必须 ∈ set 才推 (按 Trd_Common.TrdMarket int → 字符串映射, 与 keys.json::allowed_markets 配置字符串一致, e.g. “HK”/“US”/“FUTURES”). None / Some(empty) → 不做 market gate (兼容 stdio / legacy / 未配 allowed_markets 的 key).

allowed_acc_ids_snapshot 同样注册时快照, SIGHUP 重载不影响 已注册订阅者. 用户需重新 futu_sub_acc_push 才应用新 scope. 配套 main auth (guard.rs / require_acc_read_with_acc_id) 仍在 tool 调用 时 enforce, 这是 defense-in-depth 层 (push 走 server-initiated channel 绕过 tool 调用 → 必须独立 enforce).

§registered_at: Instant

注册时间(用于 session 硬上限清理,4h 默认 TTL)

§owner_key_id: Option<String>

v1.4.103 (codex 50 F6 / 53 F4 — B8): owner key id (KeyRecord.id). 注册时填的 caller key id (HTTP Bearer 或 startup key); 用于 unsub ownership check — 任何 caller 拿到 session_id 后想 unsub 必须 key id 匹配 owner_key_id (admin scope 例外).

None = legacy / stdio 模式无 key (ownership 退化为 “anyone can unsub”, 与本来 v1.4.102 行为一致).

Trait Implementations§

Source§

impl Clone for PushSubscriber

Source§

fn clone(&self) -> PushSubscriber

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more