a2a_http_client
Crate: a2a_http_client · Path: crates/a2a_http_client
Description (Cargo.toml): A2A HTTP client - WASM default, native testing support
Target-adaptive A2A HTTP client: uses Spin SDK on WASM and Reqwest on native, with identical public APIs across both targets. Includes activation-aware retry logic for KEDA scale-to-zero cold starts with exponential backoff and idempotency keys.
Feature flags
Section titled “Feature flags”From crates/a2a_http_client/Cargo.toml:
| Feature | Purpose |
|---|---|
default | No features enabled by default |
observability | Emit OTEL spans/metrics + W3C trace propagation (via observability crate) |
streaming | SSE streaming support (native only: futures-util, async-stream, a2a_protocol_core/event-stream) |
Public API (from src/lib.rs)
Section titled “Public API (from src/lib.rs)”Modules: activation (always), wasm_client / native_client (target-selected)
Core types:
Client— A2A HTTP client (target-adaptive: Spin SDK or Reqwest)Client::external(url)— create client for a remote endpointclient.call(method, params)— send a JSON-RPC requestclient.call_with_activation(method, params, config, request_id)— call with cold-start retryclient.with_header(key, value)— add custom header
ClientError/RpcError— error typesActivationConfig— retry configuration (max retries, backoff, cold-start timeout)activation_delay,idempotency_key,retry_with_activation— retry helperscheck_connectivity— probe server reachability
Re-exports:
- From
a2a_protocol_core:Message,Task,A2A_PROTOCOL_VERSION - From
protocol_transport_core:JsonRpcError,JsonRpcId,JsonRpcRequest,JsonRpcResponse,StreamingPolicy,JSONRPC_VERSION
Example sketch
Section titled “Example sketch”use a2a_http_client::{Client, ActivationConfig};use serde_json::json;
let client = Client::external("http://my-agent.default.agentmesh/a2a") .with_header("Authorization".into(), "Bearer token".into());
// Simple calllet result = client.call("message/send", json!({ "message": { "role": "user", "parts": [{"text": "Hello"}] }})).await?;
// With KEDA activation-aware retrieslet config = ActivationConfig::default();let result = client.call_with_activation( "message/send", params, &config, "req-123").await?;Full API reference: cargo doc -p a2a_http_client --no-deps