pub struct WsTransport {
pub address: String,
pub token: Option<String>,
}Expand description
Transport implementation using WebSocket.
Fields§
§address: StringThe worker’s base address (ws://host:port); rewritten to
http(s):// for the bulk upload/download endpoints.
token: Option<String>Bearer token appended to every connection when the worker requires authentication.
Implementations§
Source§impl WsTransport
impl WsTransport
Sourcepub fn new(address: impl Into<String>, token: Option<String>) -> Self
pub fn new(address: impl Into<String>, token: Option<String>) -> Self
A transport to the worker at address, authenticating with
token if given. Connections are opened per call, not held.
Sourcepub fn send_msg(&self, msg: &CoordinatorToWorker) -> Result<WorkerToCoordinator>
pub fn send_msg(&self, msg: &CoordinatorToWorker) -> Result<WorkerToCoordinator>
Send a CoordinatorToWorker message and wait for the response.
Public because a caller that builds its own plan — the Python
bindings decide which worker gets which filters, which is policy,
not transport — should not have to open its own socket to ship it.
A second connect_async elsewhere is a second place to get the
frame-size configuration wrong.
Sourcepub fn notify(&self, msg: &CoordinatorToWorker) -> Result<()>
pub fn notify(&self, msg: &CoordinatorToWorker) -> Result<()>
Send a message without waiting for an answer.
Shutdown is the one that needs this: the worker is not going to
reply, so WsTransport::send_msg would block until the socket
closed.
Sourcepub fn upload(&self, value: &Value) -> Result<DataRef>
pub fn upload(&self, value: &Value) -> Result<DataRef>
Upload a value to the worker’s /upload endpoint, for payloads too
large to travel inline in a WebSocket message.
Sourcepub fn stream_plan(
&self,
plan: SerializedPlan,
chunks: Vec<Value>,
) -> Result<Value>
pub fn stream_plan( &self, plan: SerializedPlan, chunks: Vec<Value>, ) -> Result<Value>
Ship a plan and a stream of chunks over one WebSocket, collecting results as they come back.
The binary side of the protocol. It lived in the Python bindings,
which meant a second hand-rolled connect_async and a second copy
of the msgpack StreamMessage framing, a crate away from the enum
that defines it.
Sourcepub fn resolve_output(&self, delivery: &OutputDelivery) -> Result<Value>
pub fn resolve_output(&self, delivery: &OutputDelivery) -> Result<Value>
Resolve OutputDelivery — inline or download via HTTP.
Trait Implementations§
Source§impl Transport for WsTransport
impl Transport for WsTransport
Source§fn execute(
&self,
plan: &ExecutionPlan,
_filters: &NodeCatalog,
input: &Value,
mode: &RunMode,
seed: Option<i64>,
) -> Result<(Value, HashMap<String, Value>)>
fn execute( &self, plan: &ExecutionPlan, _filters: &NodeCatalog, input: &Value, mode: &RunMode, seed: Option<i64>, ) -> Result<(Value, HashMap<String, Value>)>
Source§fn get_state(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
fn get_state(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
Source§fn set_state(&self, states: &HashMap<String, Value>) -> Result<()>
fn set_state(&self, states: &HashMap<String, Value>) -> Result<()>
Source§fn get_gradients(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
fn get_gradients(&self, node_ids: &[String]) -> Result<HashMap<String, Value>>
Auto Trait Implementations§
impl Freeze for WsTransport
impl RefUnwindSafe for WsTransport
impl Send for WsTransport
impl Sync for WsTransport
impl Unpin for WsTransport
impl UnsafeUnpin for WsTransport
impl UnwindSafe for WsTransport
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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