Ergonomic Rust client for Angzarr gRPC services.
This crate provides typed clients with fluent builder APIs for interacting
with Angzarr aggregate coordinator and query services.
Quick Start
use angzarr_client::{DomainClient, CommandBuilderExt, QueryBuilderExt};
use uuid::Uuid;
async fn example() -> angzarr_client::Result<()> {
let client = DomainClient::connect("http://localhost:1310").await?;
let cart_id = Uuid::new_v4();
let response = client.aggregate
.command("cart", cart_id)
.with_command("type.googleapis.com/examples.CreateCart", &create_cart)
.execute()
.await?;
let events = client.query
.query("cart", cart_id)
.range(0)
.get_pages()
.await?;
Ok(())
}
Mocking for Tests
Implement the GatewayClient and QueryClient traits to create mock clients:
use angzarr_client::traits::{GatewayClient, QueryClient};
use angzarr_client::proto::CommandBook;
use async_trait::async_trait;
struct MockAggregate;
#[async_trait]
impl GatewayClient for MockAggregate {
async fn execute(&self, _cmd: CommandBook)
-> angzarr_client::Result<angzarr_client::proto::CommandResponse>
{
Ok(angzarr_client::proto::CommandResponse::default())
}
}