pub struct ControlChannel { /* private fields */ }Expand description
The shared control-WS transport. Construct one per live session handle.
Implementations§
Source§impl ControlChannel
impl ControlChannel
pub fn new( control_url: impl Into<String>, headers: Vec<(String, String)>, call_timeout_ms: Option<u64>, ) -> Self
Sourcepub fn set_control_url(&self, url: impl Into<String>)
pub fn set_control_url(&self, url: impl Into<String>)
Point the channel at a (possibly new) control URL.
Sourcepub async fn connect(&self) -> Result<(), SolariError>
pub async fn connect(&self) -> Result<(), SolariError>
Open the control WebSocket. Idempotent: concurrent callers serialize on
connecting, and an already-open socket resolves immediately. Transient
fast-failing connects are retried (not a full connect timeout).
Sourcepub async fn reconnect(&self) -> Result<(), SolariError>
pub async fn reconnect(&self) -> Result<(), SolariError>
Reconnect after a drop (re-opens the socket).
Sourcepub async fn call(
&self,
method: &str,
params: Value,
) -> Result<Value, SolariError>
pub async fn call( &self, method: &str, params: Value, ) -> Result<Value, SolariError>
Send one JSON-RPC call and await its correlated reply.
Sourcepub fn register_command(&self, cmd_id: &str) -> UnboundedReceiver<AsyncFrame>
pub fn register_command(&self, cmd_id: &str) -> UnboundedReceiver<AsyncFrame>
Register a receiver for a command’s cmd.data + cmd.exit frames, keyed
on cmdId. Flushes any orphan frames that beat this registration.
If the channel is ALREADY torn down when this is called, return a
receiver whose sender is dropped immediately — its first recv() yields
None, so the caller’s wait resolves to “Control channel closed” instead
of blocking forever. A caller registers this AFTER the cmd.start reply
resolves; if the channel closed in that window fail_all has already
cleared frame_handlers, so a fresh sender inserted here would never be
dropped and the wait would hang. This window is genuinely reachable: the
read task runs concurrently and can call fail_all between the reply and
this registration.
Sourcepub fn unregister_command(&self, cmd_id: &str)
pub fn unregister_command(&self, cmd_id: &str)
Drop a command’s frame handlers (its terminal cmd.exit was seen).
Trait Implementations§
Source§impl Drop for ControlChannel
Dropping the last reference closes the socket. Without this the reader task kept the channel state alive, the state kept
the outbound sender alive, and the writer task waited on that sender, so a dropped Sandbox left its socket and both
tasks running until the server hung up.
impl Drop for ControlChannel
Dropping the last reference closes the socket. Without this the reader task kept the channel state alive, the state kept
the outbound sender alive, and the writer task waited on that sender, so a dropped Sandbox left its socket and both
tasks running until the server hung up.