pub struct InputRouteTable { /* private fields */ }Expand description
Every input’s plane state, and the reader threads behind the attached ones.
Implementations§
Source§impl InputRouteTable
impl InputRouteTable
Sourcepub fn plane(&self, input: &DataId) -> RoutePlane
pub fn plane(&self, input: &DataId) -> RoutePlane
The plane one input reads from.
Sourcepub fn planes(&self) -> Vec<(DataId, RoutePlane)>
pub fn planes(&self) -> Vec<(DataId, RoutePlane)>
The plane every input the daemon has spoken about reads from, sorted.
Sourcepub fn segment(&self, input: &DataId) -> Option<ShmSegmentSpec>
pub fn segment(&self, input: &DataId) -> Option<ShmSegmentSpec>
The segment one input is attached to.
Sourcepub fn attached_count(&self) -> usize
pub fn attached_count(&self) -> usize
How many inputs read from a ring right now.
Sourcepub fn stats(&self) -> InputPlaneStats
pub fn stats(&self) -> InputPlaneStats
A snapshot of the counters.
Sourcepub fn count_refusal(&self)
pub fn count_refusal(&self)
Records one upgrade this node could not take up.
Sourcepub fn attach(
&self,
shared: &Arc<SessionShared>,
input: &DataId,
source: &PortRef,
segment: &ShmSegmentSpec,
) -> Result<()>
pub fn attach( &self, shared: &Arc<SessionShared>, input: &DataId, source: &PortRef, segment: &ShmSegmentSpec, ) -> Result<()>
Attaches input to segment and starts reading it (§6.3).
Idempotent for the generation already attached: a repeated offer for the same incarnation is answered by leaving the working reader alone. A different generation replaces it, which is the producer-restart case — the old ring is gone and its reader has nothing left to read.
§Errors
NodeError::Shm when the segment cannot be opened, verified or read,
and NodeError::Pattern when the daemon’s segment name does not
describe the producer the event names. Either leaves the input on the
daemon path, which is the honest outcome (§6.2: never sleep-retry).
Sourcepub fn detach(&self, input: &DataId) -> bool
pub fn detach(&self, input: &DataId) -> bool
Takes input off the ring, if it was on one.
Returns whether anything was attached. The reader drains what is
resident before it exits — §6.2’s rule for a producer that goes away
is that the daemon “marks closed, lets consumers drain, and unlinks”,
and a consumer that stopped reading the instant it was told to detach
would throw away messages the producer had already committed.
The input is on the daemon path from this instant, so anything the daemon sends next is delivered inline and nothing arrives twice: the ring holds only what was written before the detach.
Sourcepub fn close_input(
&self,
input: &DataId,
event: QueuedEvent,
) -> Option<QueuedEvent>
pub fn close_input( &self, input: &DataId, event: QueuedEvent, ) -> Option<QueuedEvent>
Delivers input’s closure behind whatever its ring still holds.
Returns None when a reader took the event, and gives it back —
never drops it — when the input is not on a ring and the caller should
queue it itself.
§Why the closure cannot simply be queued
A producer that finishes commits its last frame into the ring and only then tells the daemon, which tells this consumer. That message travels on the control connection, which routinely overtakes a sample still being read from the ring — so queueing the closure directly would put “this input is finished” in front of the message that finished it, and a node that stops reading on the closure (every node) would lose the last frame of every stream.
Handing it to the reader instead makes the ordering structural: the reader drains, pushes the samples, pushes the closure, and exits.
Sourcepub fn drain_all(&self) -> usize
pub fn drain_all(&self) -> usize
Finishes every ring reader, so nothing is still in flight.
The InputRouteTable::close_input hand-off orders one input’s
closure behind its own ring. astrs_wire::NodeEvent::AllInputsClosed
has no input to hang off: the daemon sends it straight to the session,
so it arrives on the node’s control lane, which is served before any
data — and it is terminal
(astrs_wire::NodeEvent::is_terminal), so a node that winds down on
it (astrs-record-node and examples/rust-pipeline’s recorder both do)
would drop whatever a ring was still draining.
So the session drains first and pushes it second. This does wait —
bounded by RECV_SLICE per reader — which is acceptable here and
nowhere else: every input has just been declared finished, so there is
nothing left for the session to be responsive to.
Returns how many readers were waited for.
Sourcepub fn close(&self)
pub fn close(&self)
Detaches every input and waits for every reader to exit.
Called when the session ends. Waiting matters: a reader still holding a
astrs_shm::Sample holds a ring slot, and a process that exits
without releasing its consumer-table entry leaves the daemon to reclaim
it on a timeout instead of immediately.