feat(websocket): WsTimeouts request extension for WS pump knobs (WS-17)
- WsTimeouts { idle, write } request extension mirrors ChannelsPolicy:
a deployment layers it on a WS route (bare-registry routes included)
to set the pump knobs per route
- precedence: extension present replaces the router state entirely;
absent falls back to SessionState (adapter-configured idle) and the
crate default write window — a Default impl never clobbers the
adapter-configured idle knob
- upgrade.rs module + handler docs now state the real defaults for
bare-registry routes (60 s idle + 60 s write, 64-session semaphore,
handler-private WsSessions) and the extension surface
- split_ws_to_bytes_idle_with_write exposes the WS-18 write window to
run_channels_session; acceptance test drives a bare-registry route
with a 150 ms extension idle window (1001 eviction observed)
Verification: scripts/verify.sh OK (343 passed), test-support suite
ok, clippy -D warnings clean, fmt clean
This commit is contained in:
@@ -655,10 +655,25 @@ pub fn split_ws_to_bytes(socket: WebSocket) -> (WsByteStream, WsPumps) {
|
||||
/// adapter is the single seam between axum's WS and alkcall's
|
||||
/// byte-oriented channels machinery; shared with `from_wss`.
|
||||
/// `idle_timeout` (WS-01): `None` = no idle bound, `Some(d)` closes
|
||||
/// the read with 1001 after `d` without an inbound WS message.
|
||||
/// the read with 1001 after `d` without inbound chunk progress. The
|
||||
/// write pump runs with [`crate::websocket::DEFAULT_WS_WRITE_TIMEOUT`]
|
||||
/// — see [`split_ws_to_bytes_idle_with_write`] for the WS-18
|
||||
/// configurable form.
|
||||
pub fn split_ws_to_bytes_idle(
|
||||
socket: WebSocket,
|
||||
idle_timeout: Option<Duration>,
|
||||
) -> (WsByteStream, WsPumps) {
|
||||
split_ws_to_bytes_idle_with_write(socket, idle_timeout, None)
|
||||
}
|
||||
|
||||
/// [`split_ws_to_bytes_idle`] with an explicit WS-18 write-progress
|
||||
/// window: `None` = the crate default
|
||||
/// ([`DEFAULT_WS_WRITE_TIMEOUT`](crate::websocket::DEFAULT_WS_WRITE_TIMEOUT)),
|
||||
/// `Some(d)` a deployment-set window.
|
||||
pub fn split_ws_to_bytes_idle_with_write(
|
||||
socket: WebSocket,
|
||||
idle_timeout: Option<Duration>,
|
||||
write_timeout: Option<Duration>,
|
||||
) -> (WsByteStream, WsPumps) {
|
||||
let (ws_sink, ws_stream) = socket.split();
|
||||
let (read_tx, read_rx) = mpsc::channel::<Vec<u8>>(READ_SLOTS);
|
||||
@@ -690,7 +705,7 @@ pub fn split_ws_to_bytes_idle(
|
||||
ws_sink,
|
||||
write_rx,
|
||||
write_error_slot,
|
||||
Some(crate::websocket::DEFAULT_WS_WRITE_TIMEOUT),
|
||||
Some(write_timeout.unwrap_or(crate::websocket::DEFAULT_WS_WRITE_TIMEOUT)),
|
||||
));
|
||||
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user