Module endpoint

Module endpoint 

Source
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§

EndpointBuilder
Staged builder root for endpoints.
InMemoryEndpoint
An in-memory FIFO endpoint for quick testing.
InMemoryInOnlyEndpoint
In-only endpoint: supports sending but not receiving (try_receive returns None).
InOnlyInMemoryEndpointBuilder
Builder for in-only (send only) in-memory endpoint.
InOnlyStage
InOutQueueEndpointBuilder
Builder for in-out (send + receive) in-memory endpoint.
InOutStage

Enums§

EndpointSource
Source metadata describing origin of messages entering an endpoint.

Traits§

Endpoint
A trait representing a message endpoint for sending and receiving Exchange objects.