Skip to main content

Crate af_web

Crate af_web 

Source
Expand description

Reusable HTTP/gRPC host infrastructure for Agent Factory services.

A service composes its product routes and wraps them:

let app = with_standard_middleware(
    Router::new().route("/health", get(health)).merge(product_routes),
);

Re-exports§

pub use error::ApiError;
pub use middleware::latency_slo;
pub use middleware::rate_limit;
pub use middleware::request_id;
pub use middleware::RateLimiter;
pub use middleware::SLO_BUDGET_MS;

Modules§

error
JSON error envelope. Port of the reusable shape of agent_core/api/errors.py.
middleware
Cross-cutting middleware. Ports the reusable concerns of agent_core/api/: request-id propagation (request_id) and the API latency SLO (latency_slo).

Structs§

EdgeConfig
Production edge limits shared by reference hosts.
Readiness
Mutable readiness signal; liveness remains independent.
RequestId
Transport request identity used for tracing and idempotency.

Functions§

base_router
A Router preseeded with GET /health. Services merge their routes onto it.
health
Standard health endpoint payload.
join_tasks
Joins background tasks within a bounded shutdown grace period.
liveness
Liveness endpoint; success means the process event loop is responsive.
metrics
Baseline metric shared by reference hosts. Products merge their own metric families into the same endpoint when they need richer observability.
operations_router
Router exposing separate process liveness and dependency readiness.
readiness
Readiness endpoint backed by the host’s dependency state.
resolve_tonic_context
Resolves verified caller context from tonic metadata for every gRPC service.
shutdown_signal
Waits for SIGINT/SIGTERM and cancels all host tasks.
supervise_tasks
Fails readiness and cancels sibling workers if any host task exits early. Returns true only for a requested shutdown with all workers drained.
with_edge_middleware
Applies bounded production edge controls. CORS is deny-by-default.
with_standard_middleware
Wrap a router with the standard middleware stack: latency SLO (outermost, so it times everything) over request-id (so the id exists for SLO logs).