Skip to content

Commit e15eede

Browse files
Merge pull request #698 from Mark-Simulacrum/richer-interface-collector
Remove single-string API boundary
2 parents cd5529f + 358653a commit e15eede

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

collector/src/api.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ pub mod collected {
2222
// nothing
2323
}
2424
}
25+
26+
pub mod next_commit {
27+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
28+
pub struct Response {
29+
pub commit: Option<String>,
30+
}
31+
}

collector/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,14 @@ fn bench_next(
171171
) -> anyhow::Result<()> {
172172
println!("processing commits");
173173
let client = reqwest::blocking::Client::new();
174-
let commit: Option<String> = client
174+
let response: collector::api::next_commit::Response = client
175175
.get(&format!("{}/perf/next_commit", site_url))
176176
.send()?
177177
.json()?;
178-
let commit = if let Some(c) = commit {
178+
let commit = if let Some(c) = response.commit {
179179
c
180180
} else {
181+
println!("no commit to benchmark");
181182
// no missing commits
182183
return Ok(());
183184
};

site/src/server.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,15 @@ pub async fn handle_status_page(data: Arc<InputData>) -> status::Response {
288288
}
289289
}
290290

291-
pub async fn handle_next_commit(data: Arc<InputData>) -> Option<String> {
292-
data.missing_commits()
291+
pub async fn handle_next_commit(data: Arc<InputData>) -> collector::api::next_commit::Response {
292+
let commit = data
293+
.missing_commits()
293294
.await
294295
.iter()
295296
.next()
296-
.map(|c| c.0.sha.to_string())
297+
.map(|c| c.0.sha.to_string());
298+
299+
collector::api::next_commit::Response { commit }
297300
}
298301

299302
struct CommitIdxCache {

0 commit comments

Comments
 (0)