1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! Client library for the perfgate baseline service.
//!
//! This crate provides a client for interacting with the perfgate baseline
//! service API, including:
//!
//! - Uploading and downloading baselines
//! - Listing baselines with filtering
//! - Promoting and deleting baselines
//! - Health checking
//! - Automatic fallback to local storage when the server is unavailable
//!
//! Part of the [perfgate](https://github.com/EffortlessMetrics/perfgate) workspace.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use perfgate_client::{BaselineClient, ClientConfig, ListBaselinesQuery};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a client
//! let config = ClientConfig::new("https://perfgate.example.com/api/v1")
//! .with_api_key("your-api-key");
//!
//! let client = BaselineClient::new(config)?;
//!
//! // Check server health
//! let health = client.health_check().await?;
//! println!("Server status: {}", health.status);
//!
//! // List baselines
//! let query = ListBaselinesQuery::new().with_limit(10);
//! let response = client.list_baselines("my-project", &query).await?;
//!
//! for baseline in &response.baselines {
//! println!("{}: {}", baseline.benchmark, baseline.version);
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Fallback Storage
//!
//! When the server is unavailable, the client can fall back to local file storage:
//!
//! ```rust,no_run
//! use perfgate_client::{BaselineClient, ClientConfig, FallbackClient, FallbackStorage};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = ClientConfig::new("https://perfgate.example.com/api/v1")
//! .with_api_key("your-api-key")
//! .with_fallback(FallbackStorage::local("./baselines"));
//!
//! let client = BaselineClient::new(config)?;
//! let fallback_client = FallbackClient::new(
//! client,
//! Some(FallbackStorage::local("./baselines")),
//! );
//!
//! // This will fall back to local storage if the server is unavailable
//! let baseline = fallback_client
//! .get_latest_baseline("my-project", "my-bench")
//! .await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Error Handling
//!
//! The client provides detailed error types for different failure scenarios:
//!
//! ```rust,no_run
//! use perfgate_client::{BaselineClient, ClientConfig, ClientError};
//!
//! #[tokio::main]
//! async fn main() {
//! let config = ClientConfig::new("https://perfgate.example.com/api/v1");
//! let client = BaselineClient::new(config).unwrap();
//!
//! match client.get_latest_baseline("my-project", "my-bench").await {
//! Ok(baseline) => println!("Got baseline: {}", baseline.id),
//! Err(ClientError::NotFoundError(msg)) => {
//! eprintln!("Baseline not found: {}", msg);
//! }
//! Err(ClientError::AuthError(msg)) => {
//! eprintln!("Authentication failed: {}", msg);
//! }
//! Err(ClientError::ConnectionError(msg)) => {
//! eprintln!("Server unavailable: {}", msg);
//! }
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
// Re-export main types at the crate root for convenience
pub use BaselineClient;
pub use ;
pub use ClientError;
pub use FallbackClient;
pub use ;