pub struct SharedWsClient { /* private fields */ }Expand description
Shared tokio-tungstenite-backed WebSocket port implementation.
入站读任务有两条路径(按是否注入 inbound):
- push(native/FFI engine_loop):注入
(id, tick_tx)→ 读任务把数据帧作Tick::Inbound直接喂泵,连接关闭/出错作Tick::Disconnected。生产 engine_loop 从不调recv(), 入站全靠此通道(A2,HX 入站不变量)。读任务独立持 stream 半边,不碰 send 锁。 - pull(兼容 / 单测):无
inbound→ 读任务塞内部frame_rx,由平台生命周期 API 拉取。
Implementations§
pub fn new(config: HostNetworkConfig) -> Result<Self, PortError>
pub fn with_registry( config: HostNetworkConfig, headers: HostHeaderRegistry, ) -> Result<Self, PortError>
pub fn headers(&self) -> HostHeaderRegistry
Sourcepub fn with_inbound_tick(self, id: TransportId, tick_tx: Sender<Tick>) -> Self
pub fn with_inbound_tick(self, id: TransportId, tick_tx: Sender<Tick>) -> Self
注入入站推送通道(native/FFI engine_loop 路径,A2)。
设置后,connect 的读任务把数据帧作 Tick::Inbound 直发 tick_tx、
连接关闭/出错作 Tick::Disconnected(id),而非塞内部 frame_rx。
pub fn with_stamped_inbound_tick( self, id: TransportId, tick_tx: TickIngressSender, ) -> Self
pub fn with_metric_sink(self, metrics: Arc<dyn AsyncMetricSink>) -> Self
Sourcepub async fn connect(&mut self) -> Result<WsConnectionActivation, PortError>
pub async fn connect(&mut self) -> Result<WsConnectionActivation, PortError>
完成物理握手,但保持 reader 暂停。
返回的 activation 必须在 sender 已进入平台路由表后消费;这样业务处理
Tick::Connected 时,Effect::Send 一定能命中当前连接。
pub async fn recv(&self) -> Result<Option<Bytes>, PortError>
pub async fn close(&self) -> Result<(), PortError>
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request