pub struct DagBuilder { /* private fields */ }Expand description
Fluent builder for constructing StreamingDag topologies.
Constructed in Ring 2. Once build() is called, the topology is
immutable and can be executed in Ring 0.
§Example
use laminar_core::dag::DagBuilder;
let dag = DagBuilder::new()
.source("trades", schema.clone())
.operator("dedup", schema.clone())
.operator("normalize", schema.clone())
.connect("trades", "dedup")
.connect("dedup", "normalize")
.fan_out("normalize", |b| {
b.branch("vwap", schema.clone())
.branch("anomaly", schema.clone())
.branch("position", schema.clone())
})
.sink_for("vwap", "analytics_sink", schema.clone())
.sink_for("anomaly", "alert_sink", schema.clone())
.sink_for("position", "risk_sink", schema.clone())
.build()?;Implementations§
Source§impl DagBuilder
impl DagBuilder
Sourcepub fn source(self, name: &str, schema: SchemaRef) -> Self
pub fn source(self, name: &str, schema: SchemaRef) -> Self
Adds a source node to the DAG.
Source nodes are entry points that receive data from external systems via the Connector SDK.
Sourcepub fn operator(self, name: &str, schema: SchemaRef) -> Self
pub fn operator(self, name: &str, schema: SchemaRef) -> Self
Adds a stateful operator node to the DAG.
Sourcepub fn stateless_operator(self, name: &str, schema: SchemaRef) -> Self
pub fn stateless_operator(self, name: &str, schema: SchemaRef) -> Self
Adds a stateless operator node to the DAG.
Sourcepub fn materialized_view(self, name: &str, schema: SchemaRef) -> Self
pub fn materialized_view(self, name: &str, schema: SchemaRef) -> Self
Adds a materialized view node to the DAG.
Sourcepub fn fan_out<F>(self, shared_node: &str, branches: F) -> Self
pub fn fan_out<F>(self, shared_node: &str, branches: F) -> Self
Creates a fan-out from a shared stage to multiple branches.
The branches closure receives a FanOutBuilder that allows
adding multiple downstream branches from the shared node.
Each branch is automatically connected to the shared node.
Sourcepub fn sink_for(
self,
upstream: &str,
sink_name: &str,
schema: SchemaRef,
) -> Self
pub fn sink_for( self, upstream: &str, sink_name: &str, schema: SchemaRef, ) -> Self
Adds a sink node and connects it to an upstream node.
Sourcepub fn sink(self, name: &str, schema: SchemaRef) -> Self
pub fn sink(self, name: &str, schema: SchemaRef) -> Self
Adds a sink node to the DAG (without auto-connecting).
Use connect() to manually wire upstream nodes.
Sourcepub fn build(self) -> Result<StreamingDag, DagError>
pub fn build(self) -> Result<StreamingDag, DagError>
Builds the immutable DAG topology.
Validates the topology (acyclic, connected, schema-compatible), computes topological order, derives channel types, and identifies shared stages.
§Errors
Returns DagError::CycleDetected if the graph contains cycles.
Returns DagError::DisconnectedNode if a node has no connections.
Returns DagError::NodeNotFound if an edge references a missing node.
Returns DagError::DuplicateNode if nodes have duplicate names.
Returns DagError::EmptyDag if no nodes were added.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DagBuilder
impl RefUnwindSafe for DagBuilder
impl Send for DagBuilder
impl Sync for DagBuilder
impl Unpin for DagBuilder
impl UnsafeUnpin for DagBuilder
impl UnwindSafe for DagBuilder
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more