| Crates.io | allora-http |
| lib.rs | allora-http |
| version | 0.0.2 |
| created_at | 2025-11-26 04:28:01.830017+00 |
| updated_at | 2025-11-26 16:58:35.557796+00 |
| description | HTTP inbound/outbound adapters for Allora integration flows (request/reply & fire-and-forget). |
| homepage | https://github.com/fialucci/allora |
| repository | https://github.com/fialucci/allora |
| max_upload_size | |
| id | 1950933 |
| size | 68,458 |
HTTP adapters for the Allora integration library.
allora-http connects HTTP requests and responses to Allora channels and exchanges. It lets you expose
webhook-style HTTP endpoints as inbound gateways into your flows, and send HTTP requests from within those flows as
outbound adapters.
Most applications reach HTTP through the top-level allora crate (which re-exports these types), but you can also
depend on allora-http directly if you need lower-level control.
allora-http?allora-http provides:
Exchange instances, and forward them to channelsExchangetokio runtimeAt a high level:
Most users should access HTTP adapters through the allora facade crate, which re-exports the main adapter types and
builder traits.
Use allora-http directly when you:
allora crateApplication code can typically just enable HTTP via the top-level crate and import from there:
use allora::{HttpInboundAdapter, HttpOutboundAdapter};
Typical integration flows built with allora-http include:
HttpInboundAdapter accepts an HTTP requestExchange and sent to a channel (for example, a QueueChannel)Exchange and hands it to an HttpOutboundAdapterInbound adapters support different Message Exchange Patterns (MEPs):
InOut – wait for downstream processing and return the transformed body to the callerInOnly202 – immediately return HTTP 202 and continue processing asynchronouslyThis example shows a minimal HTTP inbound adapter that:
127.0.0.1 on an ephemeral portQueueChannel as an Exchangeuse allora_core::{
channel::{PollableChannel, QueueChannel},
message::{Exchange, Message},
};
use allora_http::Adapter;
use std::sync::Arc;
#[tokio::main]
async fn main() {
// Channel that will receive requests as Exchanges
let channel = Arc::new(QueueChannel::with_id("http-inbound"));
// Build an inbound HTTP adapter bound to localhost on an ephemeral port (0)
let inbound = Adapter::inbound()
.http()
.host("127.0.0.1")
.port(0)
.channel(channel.clone())
.in_only_202() // respond 202 immediately, process asynchronously
.build();
// Start serving in the background
let _server = inbound.clone().spawn_serve();
// In a real app, another task would receive from the channel in a loop
if let Some(ex) = channel.try_receive().await {
if let Some(body) = ex.in_msg.body_text() {
println!("Received HTTP payload: {body}");
}
}
}
In this pattern the HTTP adapter is a gateway: HTTP requests are turned into Exchange instances and pushed into an
Allora channel, where normal processors and services can act on them.
An outbound adapter can be used from within a processor or service to send HTTP requests based on an Exchange:
use allora_core::message::{Exchange, Message};
use allora_http::Adapter;
#[tokio::main]
async fn main() {
// Build an outbound HTTP adapter (for example, POST to a webhook)
let outbound = Adapter::outbound()
.http()
.post("http://localhost:8080/endpoint")
.build();
// Prepare an Exchange to send
let ex = Exchange::new(Message::from_text("payload"));
// Dispatch the exchange as an HTTP request
outbound
.dispatch(ex)
.await
.expect("outbound HTTP dispatch should succeed");
}
Outbound adapters typically prefer the out_msg of an exchange, falling back to in_msg when deciding what to send.
allora-http is async-first and expects a tokio runtimeallora facade, HTTP adapters integrate with the Allora runtime and configuration model (for
example, YAML-based specs)alloraThe top-level allora crate re-exports the main HTTP adapter types, so most applications only need to:
alloraHttpInboundAdapter / HttpOutboundAdapter (or use the runtime/DSL that wires them automatically)Use allora-http directly only if you need fine-grained access to the HTTP layer itself.
Check the allora crate for overall project status and roadmap.
Licensed under Apache-2.0. See the LICENSE file in the repository for details.