perfgate-client
A Rust client library for the perfgate baseline service.
Overview
perfgate-client provides a type-safe, async client for interacting with the perfgate baseline server. It handles:
- API communication with automatic retries
- Authentication via API keys
- Fallback to local storage when the server is unavailable
- Integration with the perfgate CLI
Documentation: Getting Started with Baseline Server
Features
- Full API Support: Upload, download, list, promote, and delete baselines
- Automatic Retries: Configurable retry logic with exponential backoff
- Fallback Storage: Automatic fallback to local storage when server is unavailable
- Type-Safe: Strongly typed request and response models
- Async/Await: Built on Tokio for async operations
Installation
Add this to your Cargo.toml:
[]
= { = "path/to/perfgate-client" }
Quick Start
use ;
async
Fallback Storage
When the server is unavailable, the client can fall back to local file storage:
use ;
let config = new
.with_api_key
.with_fallback;
let client = new?;
let fallback_client = new;
// This will fall back to local storage if the server is unavailable
let baseline = fallback_client
.get_latest_baseline
.await?;
Error Handling
use ;
let config = new;
let client = new.unwrap;
match client.get_latest_baseline.await
API Reference
BaselineClient
The main client for interacting with the baseline service.
| Method | Description |
|---|---|
new(config) |
Create a new client with configuration |
upload_baseline(project, request) |
Upload a new baseline |
get_latest_baseline(project, benchmark) |
Get the latest baseline for a benchmark |
get_baseline_version(project, benchmark, version) |
Get a specific baseline version |
list_baselines(project, query) |
List baselines with filtering |
delete_baseline(project, benchmark, version) |
Delete a baseline version |
promote_baseline(project, benchmark, request) |
Promote a baseline version |
health_check() |
Check server health |
is_healthy() |
Returns true if server is healthy |
FallbackClient
A client wrapper with automatic fallback to local storage.
| Method | Description |
|---|---|
new(client, fallback) |
Create a new fallback client |
get_latest_baseline(project, benchmark) |
Get latest with fallback |
get_baseline_version(project, benchmark, version) |
Get version with fallback |
upload_baseline(project, request) |
Upload with fallback |
has_fallback() |
Check if fallback is configured |
Configuration
| Type | Description |
|---|---|
ClientConfig |
Main client configuration |
RetryConfig |
Retry behavior configuration |
AuthMethod |
Authentication method (None, ApiKey, Token) |
FallbackStorage |
Fallback storage type (Local) |
License
MIT OR Apache-2.0