Rust client library for peer applications running under The Mule test orchestrator.
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() {
let mut client = the_mule::MuleClientBuilder::new()
.build()
.await
.expect("failed to build client");
client.send_status("started").await.unwrap();
loop {
let cmd = {
use std::pin::Pin;
let mut pinned = Pin::new(&mut client);
pinned.next().await
};
match cmd {
Some(the_mule::Command::Shutdown) => {
client.send_status("stopped").await.ok();
break;
}
Some(cmd) => tracing::info!("received: {:?}", cmd),
None => break,
}
}
}| Variable | Required | Description |
|---|---|---|
REDIS_URL |
yes | Redis connection URL |
PEER_NAME |
yes | This peer's name |
RUST_LOG |
no | tracing filter (e.g., info) |
- Commands: a background tokio task calls
BLPOP {peer}_command 0(truly blocking, no polling) and sends parsedCommandvalues through anmpscchannel. Your code consumes them via theStreamtrait. - Logs: a
tracingsubscriber layer captures log events and forwards them to Redis viaLPUSH {peer}_log "level|message"in a background task. - Status:
send_status()callsSET {peer}_status <value>, which triggers a keyspace notification on the orchestrator side.
MuleClientBuilder::new()— reads env vars.redis_url(url)/.peer_name(name)— override.build().await— connect, install tracing, start background tasksMuleClient::send_status(status)— push status to orchestratorimpl Stream<Item = Command>— yields parsed commandsCommandenum:Connect,Disconnect,Shutdown,Restart,Peer,Test