Skip to main content

SessionShared

Struct SessionShared 

Source
pub struct SessionShared {
Show 13 fields pub dataflow: DataflowId, pub node: NodeId, pub generation: u64, pub session: SessionId, pub spec: Arc<NodeSpawnSpec>, pub source: Arc<EventSource>, pub routes: RouteTable, pub inputs: InputRouteTable, pub zero_copy_threshold: u64, pub shm_broker: Option<PathBuf>, pub limits: FrameLimits, pub runtime: NodeRuntime, pub log_subscription: SubscriptionId, /* private fields */
}
Expand description

The state both the node and its session tasks share.

Fields§

§dataflow: DataflowId

The dataflow this node belongs to.

§node: NodeId

The node’s id.

§generation: u64

The incarnation the daemon assigned.

§session: SessionId

The greeting’s session id (§7.2).

§spec: Arc<NodeSpawnSpec>

The node’s effective specification.

§source: Arc<EventSource>

The event inbox the reader fills.

§routes: RouteTable

Per-output route state (§6.3, producer side).

§inputs: InputRouteTable

Per-input route state (§6.3, consumer side): which inputs read from a ring, and the reader threads behind them.

§zero_copy_threshold: u64

The §24.2 zero-copy threshold in bytes.

§shm_broker: Option<PathBuf>

The daemon’s segment-broker socket, when it published one (astrs_wire::NodeConfig::shm_broker).

How a RouteUpgrade turns into a mapping (§6.2: the daemon brokers the segment fds). None leaves crate::session::routes::open_producer to open the segment by name, which only a named backing supports.

§limits: FrameLimits

The negotiated frame budget.

§runtime: NodeRuntime

The runtime background work runs on.

§log_subscription: SubscriptionId

The log subscription node-emitted records carry.

Implementations§

Source§

impl SessionShared

Source

pub fn new( spec: Arc<NodeSpawnSpec>, session: SessionId, outgoing: Sender<Outgoing>, source: Arc<EventSource>, runtime: NodeRuntime, zero_copy_threshold: u64, limits: FrameLimits, ) -> Self

Builds the shared state around an established link.

Source

pub fn with_shm_broker(self, path: Option<PathBuf>) -> Self

Records the daemon’s segment-broker socket (§6.2).

A builder rather than a constructor parameter so an existing caller keeps compiling: a session without a broker is a session that opens segments by name, exactly as before.

Source

pub fn is_closed(&self) -> bool

Whether the session has ended.

Source

pub fn request_drain(&self) -> Result<()>

Queues the writer’s shutdown sentinel, so everything already queued is flushed before the connection ends.

§Errors

NodeError::DaemonGone when the session has already ended.

Source

pub fn close(&self)

Marks the session ended and wakes every waiter.

Source

pub fn hlc_now(&self) -> HlcTimestamp

The next HLC reading (§4.3).

Source

pub fn observe_remote(&self, remote: HlcTimestamp) -> bool

Folds a peer’s timestamp into this node’s clock.

§Errors

Nothing: an out-of-drift remote reading is ignored rather than propagated, because a peer with a wild clock must not be able to drag this node’s forward. The rejection is reported by the return value.

Source

pub fn stats(&self) -> SessionStats

A snapshot of the session’s counters.

Source

pub fn count_inline_send(&self)

Records one inline publish.

Source

pub fn count_zero_copy_send(&self)

Records one zero-copy publish.

Source

pub fn count_shm_fallback(&self)

Records one fall back from the zero-copy plane to the daemon path (§6.2: never sleep-retry).

Source

pub fn count_event(&self)

Records one decoded event.

Source

pub fn next_log_seq(&self) -> u64

The next log sequence number.

Source

pub fn try_send(&self, message: Outgoing) -> Result<()>

Queues a message without waiting for room.

§Errors

NodeError::Backpressure when the writer is behind, and NodeError::DaemonGone once the session has ended.

Source

pub async fn send_async(&self, message: Outgoing) -> Result<()>

Queues a message, awaiting room if the writer is behind.

§Errors

NodeError::DaemonGone once the session has ended.

Source

pub fn send_blocking(&self, message: Outgoing) -> Result<()>

Queues a message, blocking only if the writer is behind.

The synchronous path a node’s own loop uses. The fast path is a plain try_send; only a genuinely full channel touches the runtime, and the message is recovered from the failed attempt rather than rebuilt.

§Errors

NodeError::DaemonGone, or NodeError::BlockingInAsync when the channel is full and this thread may not block.

Source

pub fn send_request(&self, request: NodeRequest) -> Result<()>

Sends one protocol request (§7.3).

A successfully-sent NodeRequest::SendMessage also closes every input-to-output latency measurement this session has open (§11.3) — see EventSource::finish_deadlines. This is the one place both publish paths (crate::output::RawOutput::send_slice and crate::output::OutputSample::send) actually converge, which is what lets the deadline check live here instead of being duplicated in each of them.

§Errors

As SessionShared::send_blocking.

Source

pub async fn send_request_async(&self, request: NodeRequest) -> Result<()>

Sends one protocol request, awaiting room.

As SessionShared::send_request, a successful NodeRequest::SendMessage also closes every open deadline measurement (§11.3).

§Errors

As SessionShared::send_async.

Source

pub fn watch_extension(&self, key: &ExtensionKey) -> Receiver<Option<Vec<u8>>> ⓘ

Registers interest in the next ExtValue for key.

Source

pub fn resolve_extension( &self, key: &ExtensionKey, value: Option<Vec<u8>>, ) -> bool

Delivers an ExtValue to whoever asked for it.

Returns whether anybody was waiting; an unasked-for value is not an error (a daemon may push one), it just has nowhere to go.

Source

pub fn pending_extensions(&self) -> usize

How many extension replies are outstanding.

Source

pub fn input_source(&self, input: &DataId) -> Option<PortRef>

The producer port behind one of this node’s inputs.

Source

pub fn declares_output(&self, output: &DataId) -> bool

Whether output is one this node declares.

Trait Implementations§

Source§

impl Debug for SessionShared

Source§

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

Formats the value using the given formatter. 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