pub struct NodeBuilder { /* private fields */ }Expand description
Builds a Node.
Implementations§
Source§impl NodeBuilder
impl NodeBuilder
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
A builder seeded from ASTRS_NODE_CONFIG (§24.2).
§Errors
NodeError::MissingEnv when the variable is unset, and
NodeError::Config when it does not decode.
Sourcepub fn from_env_value(value: &str) -> Result<Self>
pub fn from_env_value(value: &str) -> Result<Self>
Sourcepub fn with_config(self, config: NodeConfig) -> Self
pub fn with_config(self, config: NodeConfig) -> Self
Seeds the builder from an already-decoded configuration.
Sourcepub const fn dataflow(self, dataflow: DataflowId) -> Self
pub const fn dataflow(self, dataflow: DataflowId) -> Self
Sets the dataflow to join.
Sourcepub fn daemon(self, endpoint: impl Into<String>) -> Self
pub fn daemon(self, endpoint: impl Into<String>) -> Self
Adds an endpoint to dial, overriding the configuration’s list.
Sourcepub fn input(self, input: impl AsRef<str>) -> Result<Self>
pub fn input(self, input: impl AsRef<str>) -> Result<Self>
Declares an input a dynamic node intends to read.
§Errors
NodeError::Id when the name fails the identifier grammar.
Sourcepub fn output(self, output: impl AsRef<str>) -> Result<Self>
pub fn output(self, output: impl AsRef<str>) -> Result<Self>
Declares an output a dynamic node intends to write.
§Errors
NodeError::Id when the name fails the identifier grammar.
Sourcepub fn subscribe(self, input: impl AsRef<str>) -> Result<Self>
pub fn subscribe(self, input: impl AsRef<str>) -> Result<Self>
Subscribes to a subset of the node’s inputs; the default is all of them.
§Errors
NodeError::Id when the name fails the identifier grammar.
Sourcepub const fn type_check(self, mode: TypeCheckMode) -> Self
pub const fn type_check(self, mode: TypeCheckMode) -> Self
Overrides the §9.2 type-check mode.
Sourcepub const fn zero_copy_threshold(self, bytes: u64) -> Self
pub const fn zero_copy_threshold(self, bytes: u64) -> Self
Overrides the §6.2 zero-copy threshold.
Sourcepub const fn parent_pid(self, pid: u32) -> Self
pub const fn parent_pid(self, pid: u32) -> Self
Watches pid as the supervising process (§4.2).
Sourcepub const fn orphan_guard(self, enabled: bool) -> Self
pub const fn orphan_guard(self, enabled: bool) -> Self
Turns the orphan guard off, for a node that outlives its launcher on purpose.
Sourcepub const fn connect_timeout(self, timeout: Duration) -> Self
pub const fn connect_timeout(self, timeout: Duration) -> Self
Bounds the dial and greeting.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
Sets the label the greeting carries, shown in astrs list.
Sourcepub fn resolved_endpoints(&self) -> Result<Vec<String>>
pub fn resolved_endpoints(&self) -> Result<Vec<String>>
The endpoints this builder will dial, in order.
Explicit endpoints win; then the configuration blob’s; then the §24.2 defaults (Unix socket, then TCP loopback).
§Errors
NodeError::BadEnv when ASTRS_DAEMON_PORT is not a port.
Sourcepub fn resolved_auth(&self) -> Result<AuthToken>
pub fn resolved_auth(&self) -> Result<AuthToken>
The token this builder will present.
§Errors
NodeError::BadEnv when ASTRS_AUTH_TOKEN is set but not valid hex.
Sourcepub fn handshake(&self) -> Result<NodeHandshake>
pub fn handshake(&self) -> Result<NodeHandshake>
The registration this builder will send.
§Errors
NodeError::Pattern when neither a configuration blob nor a node id
was supplied, since there is then nothing to register as.
Sourcepub fn provisional_spec(&self) -> Result<NodeSpawnSpec>
pub fn provisional_spec(&self) -> Result<NodeSpawnSpec>
The specification a dynamic node registers with, when it has no blob.
§Errors
Sourcepub fn connect(self) -> Result<(Node, EventStream)>
pub fn connect(self) -> Result<(Node, EventStream)>
Connects, registers and starts the session.
§Errors
NodeError::Connect when no endpoint answered, NodeError::Handshake
when the greeting was refused, and NodeError::Registration when the
daemon refused the registration.
Sourcepub async fn connect_async(self) -> Result<(Node, EventStream)>
pub async fn connect_async(self) -> Result<(Node, EventStream)>
Sourcepub async fn connect_with(
self,
runtime: NodeRuntime,
) -> Result<(Node, EventStream)>
pub async fn connect_with( self, runtime: NodeRuntime, ) -> Result<(Node, EventStream)>
Sourcepub async fn finish(
self,
link: NodeLink,
handshake: NodeHandshake,
runtime: NodeRuntime,
) -> Result<(Node, EventStream)>
pub async fn finish( self, link: NodeLink, handshake: NodeHandshake, runtime: NodeRuntime, ) -> Result<(Node, EventStream)>
Registers over an already-established link.
The seam the testing harness uses: it supplies a link over a
tokio::io::duplex pair rather than a socket.