loom.streaming.compiler

Streaming compiler: validates StreamFlow and produces CompiledPlan.

loom.streaming.compiler.compile_flow(flow, *, config)[source]

Compile a flow into an immutable plan.

Parameters:
Returns:

Immutable CompiledPlan ready for adapter wiring.

Raises:

CompilationError – If binding resolution or any validation phase fails.

Return type:

CompiledPlan

exception loom.streaming.compiler.CompilationError(errors)[source]

Bases: Exception

Raised when a StreamFlow fails validation or cannot be compiled.

Parameters:

errors (list[str]) – List of human-readable error messages.

Return type:

None

class loom.streaming.compiler.CompiledMultiSource(settings, topics, dispatch, shape, decode_strategy)[source]

Bases: object

Resolved heterogeneous Kafka source with a pre-built dispatch table.

Parameters:
  • settings (ConsumerSettings) – Resolved Kafka consumer settings.

  • topics (tuple[str, ...]) – Kafka topic names to subscribe to.

  • dispatch (DispatchTable) – Pre-built table mapping message_type and error payload_type strings to their concrete Python types, plus explicit wire-error payload types.

  • shape (StreamShape) – Declared source shape.

  • decode_strategy (Literal['record', 'batch']) – Whether to decode records individually or in batches.

class loom.streaming.compiler.CompiledNode(node, input_shape, output_shape, path=())[source]

Bases: object

DSL node annotated with input/output shapes.

Parameters:
class loom.streaming.compiler.CompiledPlan(name, source, nodes, output, error_routes, needs_async_bridge, terminal_sinks=<factory>, terminal_storage_sinks=<factory>)[source]

Bases: object

Immutable result of compiling a StreamFlow.

Parameters:
class loom.streaming.compiler.CompiledSingleSource(settings, topics, payload_type, shape, decode_strategy)[source]

Bases: object

Resolved Kafka source with a single payload type and decode strategy.

Parameters:
class loom.streaming.compiler.CompiledSink(settings, topic, partition_policy, dlq_topic=None)[source]

Bases: object

Resolved Kafka sink with partitioning.

Parameters:
class loom.streaming.compiler.CompiledStorageSink(node, config, database_config=None)[source]

Bases: object

Resolved storage sink with its DSL node and pre-fetched config section.

The adapter calls node.build_partition(config, worker_index, worker_count, bridge) at startup once per Bytewax worker to obtain the SinkPartition that handles epoch writes and shutdown. Storage backends that require async execution receive the adapter-managed AsyncBridge.

Parameters: