Expand description
Integration Patterns module: collection of Enterprise Integration Patterns (EIP) primitives.
§Provided Patterns
filter– Conditional acceptance/rejection of anExchange(Filter).content_router– Content-based routing using predicates to select a downstream processor (ContentBasedRouter).splitter– Split a single inbound message into multiple outbound messages (Splitter).aggregator– Aggregate correlated messages until a completion condition is met (Aggregator).recipient_list– Fan-out to a dynamic list of processors (RecipientList).correlation_initializer– Ensure acorrelation_id(and optional mirror header) early in a route.
§Design Notes
Patterns follow Enterprise Integration Pattern semantics adapted to idiomatic Rust:
- Trait (
Processor) keeps implementations lightweight. - Correlation handled lazily; use
CorrelationInitializeror callExchange::correlation_id(). - Each pattern lives in its own module with focused responsibilities.
§Example: Filter and Aggregator Combined
use allora_core::{route::Route , Exchange, Message};
use allora_core::patterns::{aggregator::Aggregator, correlation_initializer::CorrelationInitializer, filter::Filter};
let route = Route::new()
.add(CorrelationInitializer::with_mirror("corr"))
.add(Filter::new(|exchange: &Exchange| exchange.in_msg.body_text() == Some("keep")))
.add(Aggregator::new("corr", 2))
.build();
let mut exchange = Exchange::new(Message::from_text("keep"));
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async { route.run(&mut exchange).await.unwrap(); });
assert!(exchange.out_msg.is_none());For detailed usage, see each submodule’s own documentation and tests under tests/.
Modules§
- aggregator
- Aggregator pattern: collects messages sharing a correlation header until a configured completion size is reached, then emits a concatenated outbound text message.
- content_
router - Content-Based Router pattern: route an
Exchangeto one of several processors based on a header value. - correlation_
initializer - filter
- Filter: evaluates a boolean predicate over an
Exchangeto decide if routing continues. - recipient_
list - Recipient List pattern: fan-out a single
Exchangesequentially to multiple processors. - splitter
- Splitter pattern: derives multiple logical messages from a single inbound
Exchange.