Skip to main content

open_consumer

Function open_consumer 

Source
pub fn open_consumer(
    dataflow: DataflowId,
    source: &PortRef,
    segment: &ShmSegmentSpec,
    broker: Option<&Path>,
) -> Result<(Arc<Segment>, Consumer)>
Expand description

Opens the segment an InputRouteUpgrade names and attaches a reader to it.

The mirror of crate::session::routes::open_producer, and it checks the same two things: the name the daemon sent must be the one the producer’s (dataflow, node, output, generation) describes, and the mapped header’s digest and generation must match that key. A stale ring from a previous incarnation therefore cannot be read, which is §6.2’s crash-safety property from the consumer’s side.

§The doorbell

A consumer in a different process from its producer cannot be woken by the producer directly — the two share a mapping, not a descriptor table. The broker is the go-between: astrs_shm::SegmentClient::register_doorbell passes this consumer’s ringer over the same Unix socket that carried the segment, and the producer picks it up from the shared registry on its next commit. Without it a receive still works, but only by waiting out astrs-shm’s growing fallback slice — correct, and needlessly slow.

§Errors

NodeError::Shm when the segment cannot be opened, verified or attached to, and NodeError::Pattern when the daemon’s name does not describe the producer port the event names.