Skip to main content

NodeBuilder

Struct NodeBuilder 

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

Builds a Node.

Implementations§

Source§

impl NodeBuilder

Source

pub fn new() -> Self

An empty builder.

Source

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.

Source

pub fn from_env_value(value: &str) -> Result<Self>

A builder seeded from an explicit blob.

§Errors

NodeError::Config when the blob does not decode.

Source

pub fn with_config(self, config: NodeConfig) -> Self

Seeds the builder from an already-decoded configuration.

Source

pub fn node_id(self, node_id: impl AsRef<str>) -> Result<Self>

Sets the node’s id.

§Errors

NodeError::Id when the name fails the identifier grammar.

Source

pub const fn dataflow(self, dataflow: DataflowId) -> Self

Sets the dataflow to join.

Source

pub fn daemon(self, endpoint: impl Into<String>) -> Self

Adds an endpoint to dial, overriding the configuration’s list.

Source

pub fn auth(self, auth: AuthToken) -> Self

Sets the cluster token (§16).

Source

pub const fn dynamic(self, dynamic: bool) -> Self

Marks the node as attaching itself (§8.3).

Source

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.

Source

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.

Source

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.

Source

pub const fn type_check(self, mode: TypeCheckMode) -> Self

Overrides the §9.2 type-check mode.

Source

pub const fn zero_copy_threshold(self, bytes: u64) -> Self

Overrides the §6.2 zero-copy threshold.

Source

pub const fn parent_pid(self, pid: u32) -> Self

Watches pid as the supervising process (§4.2).

Source

pub const fn orphan_guard(self, enabled: bool) -> Self

Turns the orphan guard off, for a node that outlives its launcher on purpose.

Source

pub const fn connect_timeout(self, timeout: Duration) -> Self

Bounds the dial and greeting.

Source

pub fn label(self, label: impl Into<String>) -> Self

Sets the label the greeting carries, shown in astrs list.

Source

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.

Source

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.

Source

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.

Source

pub fn provisional_spec(&self) -> Result<NodeSpawnSpec>

The specification a dynamic node registers with, when it has no blob.

§Errors

As NodeBuilder::handshake.

Source

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.

Source

pub async fn connect_async(self) -> Result<(Node, EventStream)>

The async form of NodeBuilder::connect.

§Errors

As NodeBuilder::connect.

Source

pub async fn connect_with( self, runtime: NodeRuntime, ) -> Result<(Node, EventStream)>

Connects on a runtime the caller chose.

§Errors

As NodeBuilder::connect.

Source

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.

§Errors

As NodeBuilder::connect.

Trait Implementations§

Source§

impl Clone for NodeBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeBuilder

Source§

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

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

impl Default for NodeBuilder

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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