Skip to main content

InputRouteTable

Struct InputRouteTable 

Source
pub struct InputRouteTable { /* private fields */ }
Expand description

Every input’s plane state, and the reader threads behind the attached ones.

Implementations§

Source§

impl InputRouteTable

Source

pub fn new() -> Self

An empty table: every input on the daemon path.

Source

pub fn plane(&self, input: &DataId) -> RoutePlane

The plane one input reads from.

Source

pub fn planes(&self) -> Vec<(DataId, RoutePlane)>

The plane every input the daemon has spoken about reads from, sorted.

Source

pub fn segment(&self, input: &DataId) -> Option<ShmSegmentSpec>

The segment one input is attached to.

Source

pub fn attached_count(&self) -> usize

How many inputs read from a ring right now.

Source

pub fn stats(&self) -> InputPlaneStats

A snapshot of the counters.

Source

pub fn count_refusal(&self)

Records one upgrade this node could not take up.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for InputRouteTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InputRouteTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeDebug for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more