Skip to content

Remove single-string API boundary #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions collector/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ pub mod collected {
// nothing
}
}

pub mod next_commit {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Response {
pub commit: Option<String>,
}
}
5 changes: 3 additions & 2 deletions collector/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ fn bench_next(
) -> anyhow::Result<()> {
println!("processing commits");
let client = reqwest::blocking::Client::new();
let commit: Option<String> = client
let response: collector::api::next_commit::Response = client
.get(&format!("{}/perf/next_commit", site_url))
.send()?
.json()?;
let commit = if let Some(c) = commit {
let commit = if let Some(c) = response.commit {
c
} else {
println!("no commit to benchmark");
// no missing commits
return Ok(());
};
Expand Down
9 changes: 6 additions & 3 deletions site/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,15 @@ pub async fn handle_status_page(data: Arc<InputData>) -> status::Response {
}
}

pub async fn handle_next_commit(data: Arc<InputData>) -> Option<String> {
data.missing_commits()
pub async fn handle_next_commit(data: Arc<InputData>) -> collector::api::next_commit::Response {
let commit = data
.missing_commits()
.await
.iter()
.next()
.map(|c| c.0.sha.to_string())
.map(|c| c.0.sha.to_string());

collector::api::next_commit::Response { commit }
}

struct CommitIdxCache {
Expand Down