pub struct CtpPlugin { /* private fields */ }Expand description
CTP 网关插件(纯生产者 + 自服务)。
Implementations§
Source§impl CtpPlugin
impl CtpPlugin
Sourcepub fn with_transport(cfg: CtpConfig, trans: Box<dyn CtpTransport>) -> Self
pub fn with_transport(cfg: CtpConfig, trans: Box<dyn CtpTransport>) -> Self
注入传输层(native 桥或测试桩)。
Sourcepub fn connect(&self)
pub fn connect(&self)
连接(原稿 CtpGateway.connect 162-190:先 TD 后 MD;init_query 只是挂秒针)。
连接触发点住在本插件里(不放到核心/公共层,每个插件自持自己的连接):
宿主 start() 会经 Plugin::on_start 调它一次;要显式控制(先配后连、
断线后重连)也可以直接调。幂等由驱动守卫裁决 —— 原稿 MD 重复调用静默,
TD 重复调用转认证(776-777),两者都在 MdDriver::connect/TdDriver::connect。
原稿末尾的 init_query 只是把查询轮转注册到 EVENT_TIMER(237-240);
本 crate 的对应面是宿主 eTimer → CtpPlugin::on_timer,这里无需动作。
Sourcepub fn on_md_event(&self, ev: MdEvent)
pub fn on_md_event(&self, ev: MdEvent)
原生适配入口(native 桥的回调直接调这四个):MD 回报步进 + 总线上抛。
Sourcepub fn on_td_event(&self, ev: TdEvent)
pub fn on_td_event(&self, ev: TdEvent)
原生适配入口(native 桥的回调直接调这四个):TD 回报步进 + 总线上抛。
Sourcepub fn on_timer(&self)
pub fn on_timer(&self)
eTimer 一拍(原稿 gateway.process_timer_event):先做 1s 轻量判定 (0.7.0 轮转闸门的 3 秒兜底,必须按 1s 计,放进 2s gate 会退化成 4s) → 2s gate 轮转查询 + 行情日期刷新。这样独立出来服务测试与 native 适配。
Sourcepub fn status(&self) -> GatewayStatus
pub fn status(&self) -> GatewayStatus
状态口(0.9.0 新增;公开与 configure 同级;ask 臂 {gw}.status 走它)。
纪律:只读——不改任何守卫、不触发重连、不写日志(界面按秒级刷, 每次刷都写日志会把 eLog 环冲爆,512 行取证环就是这么饱和的)。
Sourcepub fn disconnect(&self) -> DisconnectReply
pub fn disconnect(&self) -> DisconnectReply
断开口(0.9.0 新增;裁定 1「断开 = 停会话,实例与订阅保留」)。
放掉:两侧会话(传输层 release + 驱动守卫复位,轮转闸门关闭)。
保留:插件实例、账号配置、订阅集、断开计数与「最近时刻」、持仓合并缓存、
OrderSysID 映射。恢复走『连接』(= configure 重走全链,登录后自动重订阅)。
Sourcepub fn configure(&self, r: &ConfigureReq) -> ConfigureReply
pub fn configure(&self, r: &ConfigureReq) -> ConfigureReply
配置口(公开,与 connect 同级的显式控制面;ask 臂 {gw}.configure
走的也是它)。
Trait Implementations§
Source§impl Plugin for CtpPlugin
impl Plugin for CtpPlugin
Source§fn routes(&self) -> Vec<Cow<'static, str>>
fn routes(&self) -> Vec<Cow<'static, str>>
Source§fn services(&self) -> Vec<ServiceDesc>
fn services(&self) -> Vec<ServiceDesc>
id 织入路由索引;
之后 ctx.services_of/find_service/ask_service 需要明细时由宿主现场调用本方法取。 Read moreSource§fn on_init(&self, ctx: &PluginContext)
fn on_init(&self, ctx: &PluginContext)
Source§fn on_mail(&self, event: &Event)
fn on_mail(&self, event: &Event)
Source§fn mailbox_cap(&self) -> usize
fn mailbox_cap(&self) -> usize
MAILBOX_CAP)。