Skip to main content

Crate polyoxide_ws

Crate polyoxide_ws 

Source
Expand description

§polyoxide-ws

The WebSocket kit the polyoxide socket clients share. Each block here was carried as a copy by every socket crate (five of them); this crate holds the one copy, and each venue keeps only what is its own.

  • ensure_crypto_provider installs the process-default rustls provider a tokio-tungstenite connect needs.
  • Backoff is the reconnect delay schedule.
  • Timing holds a supervised connection’s ping, staleness, backoff, connect and rotation timings, timing_setters! gives a builder its setters, and next_wait is the wait until the first deadline.
  • WsError is the one socket error, read through its Kind. polyoxide_venue::impl_ws_classification! classifies it in the venue crate that wraps it.
  • connect opens a connection within a timeout, connect_over upgrades a TCP connection a venue opened itself, with_timeout bounds a venue’s own connect, and retrying_can_fix says whether a reconnect can help after one failed.
  • Connection is the bare tier: one connection as a Stream of its frames in a Mode, with the server’s close captured, and requests correlated with their answers through Correlated.
  • Supervisor runs one supervised connection for a venue’s Protocol: pings on the wall clock, staleness, reconnect with backoff and a replay of the membership, rotation, outage markers, and membership changes through a MembershipHandle, yielding a Supervised stream.

tungstenite is re-exported, so a venue names Message and CloseFrame through this crate rather than depending on it.

Behind the test-server feature, the doc-hidden test_server module holds the scripted local server and the helpers the offline suites share. It is for tests, not consumers.

The crate depends on neither polyoxide-core nor polyoxide-venue, and builds no HTTP or signing stack, so a credential-free feed built on it stays light (AD-2). It logs under the polyoxide_ws target and never installs a subscriber.

Re-exports§

pub use tokio_tungstenite::tungstenite;

Macros§

timing_setters
Generates the timing setters a supervised builder offers, each writing the builder’s timing field, a Timing.

Structs§

Backoff
The reconnect delay schedule: doubling from an initial delay to a ceiling, and back to the start after a connection that delivered something.
Connection
One open connection, as a Stream of its frames.
MembershipHandle
Changes the membership of a running Supervised.
Supervised
A supervised connection: a Stream of the protocol’s events, and of the errors it skips past or stops on, that survives drops, stalls and rotations by reconnecting and replaying its membership.
Supervisor
Starts a supervised connection for a Protocol.
Timing
The timings a supervised connection runs on.
WsError
A WebSocket failure: a transport error, a refused upgrade, a server close, or one of the kit’s own timeouts.

Enums§

Correlated
What a frame read while a request awaits its answer is, as the caller’s matcher reads it.
Decoded
What one frame decodes to.
Kind
What kind of failure a WsError is.
Mode
Which frames a Connection yields.
Offline
What becomes of a membership change made while no connection is up.
Outage
Why a connection went down, for Protocol::disconnected, which owns it, so a protocol’s marker can carry the error.
Queue
The queue between the task and the consumer.
Recovery
What to do after a failure.

Constants§

DEFAULT_CONNECT_TIMEOUT
How long one connection attempt may take unless a venue says otherwise: the TCP connect, the TLS handshake and the WebSocket upgrade together.
MIN_BACKOFF
The shortest delay. Zero would never grow, so a dead host would be retried on every timer tick.

Traits§

Protocol
A venue’s socket protocol, as the Supervisor drives it.

Functions§

connect
Open a connection, giving up after timeout.
connect_over
Upgrade a TCP connection the caller opened itself: the TLS handshake when request is a wss:// URL, then the WebSocket upgrade.
ensure_crypto_provider
Make sure rustls has a default CryptoProvider before a connection opens.
next_wait
The wait until the first of several deadlines falls due.
retrying_can_fix
Whether reconnecting can help after a connect failed this way.
with_timeout
Run a caller’s own connect future, giving up after timeout with Kind::ConnectTimeout.

Type Aliases§

Socket
An open connection, over TLS or plain TCP.