Expand description
Endpoint abstraction: a lightweight FIFO inbox for Exchanges.
§Purpose
Endpoint represents a minimal buffering component for messages (Exchange) without
applying routing or processing logic. It is useful for:
- Simple test harnesses (inject messages, assert ordering).
- Staging / decoupling between an inbound adapter and a downstream
Channel. - Capturing outputs in integration tests when full routing is unnecessary.
For richer semantics (processors, correlation, queues of processed results) prefer
the Channel abstraction.
§Object Safety Note
The trait returns impl Future for async methods, which makes it not object-safe.
That is acceptable for current usage (direct generic or concrete types). If you need
dynamic dispatch (Box<dyn Endpoint>), refactor to use async_trait instead.
§Example
use allora_core::{Exchange, Message};
use allora_core::endpoint::{Endpoint, EndpointBuilder};
let ep = EndpointBuilder::in_out().queue().build();
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
ep.send(Exchange::new(Message::from_text("A"))).await.unwrap();
let received = ep.try_receive().await.unwrap();
assert_eq!(received.in_msg.body_text(), Some("A"));
});Structs§
- Endpoint
Builder - Staged builder root for endpoints.
- InMemory
Endpoint - An in-memory FIFO endpoint for quick testing.
- InMemory
InOnly Endpoint - In-only endpoint: supports sending but not receiving (try_receive returns None).
- InOnly
InMemory Endpoint Builder - Builder for in-only (send only) in-memory endpoint.
- InOnly
Stage - InOut
Queue Endpoint Builder - Builder for in-out (send + receive) in-memory endpoint.
- InOut
Stage
Enums§
- Endpoint
Source - Source metadata describing origin of messages entering an endpoint.