vantage-api-pool
High-performance REST API client pool for the Vantage data framework.
Provides PoolApi, a TableSource implementation backed by a concurrent HTTP client pool with
automatic pagination, prefetching, and rate limiting. Use the same Table<PoolApi, E> / entity
pattern as any other Vantage backend.
Quick start
use ;
// Create pool with 3 workers and Bearer auth
let pool = new;
// Wrap as a Vantage TableSource
let api = new;
// Use with Table and entities — auto-paginates transparently
let countries = new.with_id_column;
let all = countries.list_values.await?; // fetches all pages
// Entity access
let germany: Country = countries.get.await?;
Architecture
PoolApi (TableSource)
└── AwwPool
├── HttpClientPool (N worker threads)
│ └── EventualRequest (retry, backoff, rate limiting)
├── EventualRequestMatcher (request/response routing)
└── PaginatedStream (async Stream with prefetch)
Request flow: Table.list_values() -> PoolApi.list_table_values() -> PaginatedStream
fetches pages concurrently via AwwPool.get() -> worker threads execute HTTP requests -> responses
are matched back and yielded as stream items.
Modules
Core pool
| File | Description |
|---|---|
src/aww_pool.rs |
AwwPool — top-level pool API. Manages workers, auth tokens, and request dispatch. |
src/client_pool/http.rs |
HttpClientPool — spawns N worker threads that process HTTP requests from a channel. Handles per-worker rate limiting. |
src/eventual_request/mod.rs |
EventualRequest — wraps a single HTTP request with retry logic. Exponential backoff on 429/5xx errors. |
src/matcher/mod.rs |
EventualRequestMatcher — routes responses back to callers using ID-based matching. Async coordination between senders and receivers. |
Pagination
| File | Description |
|---|---|
src/paginator/paginated_stream.rs |
PaginatedStream — implements futures::Stream. Fetches pages via tokio tasks with configurable prefetch depth. Expects {"data": [...], "pagination": {"total_pages": N}} response format. |
src/paginator/paginated_stream2.rs |
PaginatedStream2 — alternative with sequential fetch + overlap. |
src/paginator/paginated_stream3.rs |
PaginatedStream3 — pure sequential, minimal overhead. |
src/paginator/paginated_stream4.rs |
ItemStream4 — channel-based with dedicated worker thread. |
PaginatedStream (used by PoolApi) is the best performer across all configurations.
Rate limiting
| File | Description |
|---|---|
src/rate_limit/keyed_rate_limiter.rs |
KeyedRateLimiter — per-key rate limiting with sleep-based throttling. |
src/rate_limit/policy.rs |
RateLimitPolicyEnforcer — IETF-compliant rate limit policy (returns 429 with headers). |
src/rate_limit/damper.rs |
Reserved for future adaptive dampening support; currently not implemented. |
src/rate_limit/rate_limiter.rs |
RateLimiter — simple single-key rate limiter. |
Statistics
| File | Description |
|---|---|
src/stats/mod.rs |
Stats — tracks success/error/retry counts with timing. |
src/stats/average.rs |
Average — running average computation for response times. |
src/stats/interval.rs |
Interval-based stat differencing for live reporting. |
Vantage integration
| File | Description |
|---|---|
src/pool_api.rs |
PoolApi — implements TableSource for AwwPool. list_table_values() auto-paginates by collecting a PaginatedStream. stream_table_values() exposes the stream directly for incremental processing. |
AwwPool configuration
new
Authentication
pool.with_auth_callback
Tokens are acquired lazily and cached. Multiple tokens can be rotated for APIs with per-token rate limits.
Direct pool usage
// Simple GET (auth applied automatically)
let response = pool.get.await?;
// Custom request
let request = new.post.json.build?;
let response = pool.request.await?;
Paginated streaming
use StreamExt;
let mut stream = get
.prefetch; // Keep 3 pages fetched ahead
while let Some = stream.next.await
Vantage integration
PoolApi wraps Arc<AwwPool> and implements TableSource, so it works with Table, Entity,
print_table, and all other Vantage features.
// Auto-paginates, returns all cities across all pages
let cities = for_country;
print_table.await?;
// Entity access
let rosario: City = cities.get.await?;
println!;
Expected API response format
Pagination is driven by total_pages from the first response. Pages are fetched as ?page=N query
parameters.
License
MIT OR Apache-2.0