Expand description
DSL Facade: multi-format (YAML today; JSON/XML forthcoming) configuration entry points.
This module orchestrates conversion of external textual configuration into runtime components by coordinating three layers:
- Parsers (in
spec/): format-specific translation into strongly typed specs. - Builders (in
dsl/component_builders.rs): spec -> concrete runtime objects. - Facade (this file): public ergonomic API + format inference.
§Goals
- Provide a minimal, stable surface (
build,build_channel,build_channel_from_str,build_filter,DslFormat). - Keep parsing & instantiation decoupled so additional formats/components add minimal code.
- Fail fast with clear, categorized errors (
Error::SerializationvsError::Other).
§Supported Components (v1)
- Channel (InMemory kind)
- Filter (single filter spec via
build_filterAND aggregated when present in top-levelallora.ymlintoAlloraRuntime) - Service (single service spec via
build_service; aggregation forthcoming when services spec collection is added)
§Supported Formats
- YAML (
DslFormat::Yaml) - JSON / XML reserved (emit explicit unsupported errors)
§Building a Single Channel
use allora_core::Channel;
use allora_runtime::build_channel;
let ch = build_channel("tests/fixtures/channel.yml").unwrap();
println!("channel id={}", ch.id());§Building a Single Filter
use allora_runtime::build_filter;
// Requires tests/fixtures/filter.yml present.
let f = build_filter("tests/fixtures/filter.yml").unwrap();
// apply using f.accepts(exchange)§Building a Single Service
use allora_runtime::build_service;
// Requires tests/fixtures/service.yml present.
let svc = build_service("tests/fixtures/service.yml").unwrap();
// invoke via svc.process_sync(&mut exchange)§Building Multiple Filters (collection spec)
use allora_runtime::spec::FiltersSpecYamlParser;
use allora_runtime::dsl::component_builders::build_filters_from_spec;
let raw = std::fs::read_to_string("tests/fixtures/filters.yml").unwrap();
let spec = FiltersSpecYamlParser::parse_str(&raw).unwrap();
let filters = build_filters_from_spec(spec).unwrap();
assert!(!filters.is_empty());§Building the Full Runtime (AlloraRuntime)
use allora_runtime::{build, Channel, Filter};
let rt = build("tests/fixtures/allora.yml").unwrap();
assert!(rt.channel_by_id("inbound.orders").is_some());
assert!(rt.filters().len() >= 1);Runtime accessors now: channels(), channel_by_id(), channel_count(), filters(), filter_count(), plus ownership via into_channels() / into_filters().
§Access Patterns
- Borrow:
rt.channels(),rt.filters() - Lookup:
rt.channel_by_id("inbound.orders") - Counts:
rt.channel_count(),rt.filter_count() - Consume:
rt.into_channels(),rt.into_filters()
§Error Semantics
Error::Other– I/O failures (e.g. unreadable file path)Error::Serialization– structural issues (missing fields / invalid values / unsupported version / unsupported format)
§Extension Guide (Adding New Components)
- Define data model spec (
*_spec.rs) - Add parser (
*_spec_yaml.rs) validating version + fields - Extend
AlloraSpecto hold new spec collection (e.g. filters, endpoints) - Add builder in
component_builders.rs - Augment
build_runtime_from_strto assemble new runtime objects - Add accessors on
AlloraRuntime
§Format Addition (JSON Outline)
- Introduce
*_json_parserimplementingparse_str - Branch in
build_*_from_strandbuild_runtime_from_str - Reuse existing builders (format-agnostic)
§Testing Strategy
- Parser edge cases near parser modules (
*_spec_yaml.rs) - Builder invariants in dedicated tests (channels, filters)
- Facade behavior & runtime aggregation in runtime-focused tests
§Versioning
- Each spec parser validates an explicit integer
version - Breaking changes add parallel parser modules (
*_v2_yaml.rs) preserving old behavior
§Internal Helpers (Non-Public)
build_runtime_from_str– dispatcher from raw text + format (now aggregates filters when present)build_filter_from_str– kept private
§Roadmap
- Multiple channel kinds (kafka, amqp)
- Additional pattern components (routers, splitters) aggregated in runtime
- Endpoints & adapters (HTTP, file, custom transport)
- JSON/XML DSL formats
- Expanded expression language (parentheses, negation, path navigation)
This documentation focuses on architecture & extensibility; see component modules for specifics.
Modules§
- component_
builders - DSL runtime component builders: instantiate runtime components from validated specs. This module will host builders for multiple component types (Channel, Endpoint, Adapter, etc.). Each builder converts a spec (format-agnostic, already validated) into a concrete runtime type.
- runtime
- AlloraRuntime: aggregate of built runtime components (extensible).
Enums§
- DslFormat
- Supported DSL input formats.
Functions§
- build
- Public: build full runtime from a file path (future: endpoints, filters, etc.).
- build_
channel - Convenience: build channel from a file path (auto-detect format via extension).
- build_
channel_ from_ str - Build channel from raw string + specified format.
- build_
filter - Convenience: build filter from a file path (auto-detect format via extension).
- build_
service - Convenience: build service from a file path (auto-detect format via extension).