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: DataflowIdThe dataflow this node belongs to.
node: NodeIdThe node’s id.
generation: u64The incarnation the daemon assigned.
session: SessionIdThe greeting’s session id (§7.2).
spec: Arc<NodeSpawnSpec>The node’s effective specification.
source: Arc<EventSource>The event inbox the reader fills.
routes: RouteTablePer-output route state (§6.3, producer side).
inputs: InputRouteTablePer-input route state (§6.3, consumer side): which inputs read from a ring, and the reader threads behind them.
zero_copy_threshold: u64The §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: FrameLimitsThe negotiated frame budget.
runtime: NodeRuntimeThe runtime background work runs on.
log_subscription: SubscriptionIdThe log subscription node-emitted records carry.
Implementations§
Sourcepub fn new(
spec: Arc<NodeSpawnSpec>,
session: SessionId,
outgoing: Sender<Outgoing>,
source: Arc<EventSource>,
runtime: NodeRuntime,
zero_copy_threshold: u64,
limits: FrameLimits,
) -> Self
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.
Sourcepub fn with_shm_broker(self, path: Option<PathBuf>) -> Self
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.
Sourcepub fn request_drain(&self) -> Result<()>
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.
Sourcepub fn hlc_now(&self) -> HlcTimestamp
pub fn hlc_now(&self) -> HlcTimestamp
The next HLC reading (§4.3).
Sourcepub fn observe_remote(&self, remote: HlcTimestamp) -> bool
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.
Sourcepub fn stats(&self) -> SessionStats
pub fn stats(&self) -> SessionStats
A snapshot of the session’s counters.
Sourcepub fn count_inline_send(&self)
pub fn count_inline_send(&self)
Records one inline publish.
Sourcepub fn count_zero_copy_send(&self)
pub fn count_zero_copy_send(&self)
Records one zero-copy publish.
Sourcepub fn count_shm_fallback(&self)
pub fn count_shm_fallback(&self)
Records one fall back from the zero-copy plane to the daemon path (§6.2: never sleep-retry).
Sourcepub fn count_event(&self)
pub fn count_event(&self)
Records one decoded event.
Sourcepub fn next_log_seq(&self) -> u64
pub fn next_log_seq(&self) -> u64
The next log sequence number.
Sourcepub fn try_send(&self, message: Outgoing) -> Result<()>
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.
Sourcepub async fn send_async(&self, message: Outgoing) -> Result<()>
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.
Sourcepub fn send_blocking(&self, message: Outgoing) -> Result<()>
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.
Sourcepub fn send_request(&self, request: NodeRequest) -> Result<()>
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
Sourcepub async fn send_request_async(&self, request: NodeRequest) -> Result<()>
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
Sourcepub fn watch_extension(&self, key: &ExtensionKey) -> Receiver<Option<Vec<u8>>> ⓘ
pub fn watch_extension(&self, key: &ExtensionKey) -> Receiver<Option<Vec<u8>>> ⓘ
Registers interest in the next ExtValue for key.
Sourcepub fn resolve_extension(
&self,
key: &ExtensionKey,
value: Option<Vec<u8>>,
) -> bool
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.
Sourcepub fn pending_extensions(&self) -> usize
pub fn pending_extensions(&self) -> usize
How many extension replies are outstanding.
Sourcepub fn input_source(&self, input: &DataId) -> Option<PortRef>
pub fn input_source(&self, input: &DataId) -> Option<PortRef>
The producer port behind one of this node’s inputs.
Sourcepub fn declares_output(&self, output: &DataId) -> bool
pub fn declares_output(&self, output: &DataId) -> bool
Whether output is one this node declares.