Skip to main content

Module batch

Module batch 

Source
Expand description

When a connection’s stream goes out.

A turn’s frames arrive in bursts, and most of a storm is one kind: the CLI reports its thinking tokens about every 50 of them. A batch waits for the shorter of two intervals, folds the token appends it holds into the single frame they draw as, and writes the rest out as they came - so the frame count a storm produces drops, and what any frame means does not.

Re-exports§

use std::time::Duration; 🔒
use std::time::Instant; 🔒
use axum::extract::ws::Message; 🔒
use futures_util::SinkExt; 🔒
use crate::delivery::delivery_turn; 🔒
use crate::transport::envelope::ServerMessage; 🔒
use crate::transport::WRITE_BOUND; 🔒
use crate::transport::write_within; 🔒
use crate::SeatUpdate; 🔒
use crate::SessionUpdate; 🔒

Structs§

Batch
The updates waiting for one write, and when they have waited long enough.

Constants§

FLUSH_CEILING
The longest an update waits for company, however busy the stream is.
FLUSH_INTERVAL
How long a batch waits for the updates behind it before it goes out.

Functions§

feed 🔒
Put one message in the socket’s buffer, where the batch’s flush picks it up - under the write bound, because a full buffer blocks here and a peer that stopped reading keeps it full.
flush
Write a run of updates to a client: every one its own frame - the token appends among them folded into the one frame they draw as - in the order given, and ONE flush for the lot.
folded 🔒
The run of frames as the client reads them: the token appends folded into the one frame they draw as, each survivor carrying how many of the seat’s numbers it stands for.
merge 🔒
Fold update into last when the two are consecutive token appends for one seat, and answer whether it did.