Skip to content

Commit 0d32dcd

Browse files
committed
Return job ID from enqueue_benchmark_job
1 parent c48489c commit 0d32dcd

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

database/src/pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ pub trait Connection: Send + Sync {
214214
commit_date: DateTime<Utc>,
215215
) -> anyhow::Result<()>;
216216

217-
/// Add a benchmark job to the job queue.
217+
/// Add a benchmark job to the job queue and return its ID.
218218
async fn enqueue_benchmark_job(
219219
&self,
220220
request_tag: &str,
221221
target: Target,
222222
backend: CodegenBackend,
223223
profile: Profile,
224224
benchmark_set: u32,
225-
) -> anyhow::Result<()>;
225+
) -> anyhow::Result<u32>;
226226

227227
/// Returns a set of compile-time benchmark test cases that were already computed for the
228228
/// given artifact.

database/src/pool/postgres.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,9 +1637,10 @@ where
16371637
backend: CodegenBackend,
16381638
profile: Profile,
16391639
benchmark_set: u32,
1640-
) -> anyhow::Result<()> {
1641-
self.conn()
1642-
.execute(
1640+
) -> anyhow::Result<u32> {
1641+
let row = self
1642+
.conn()
1643+
.query_one(
16431644
r#"
16441645
INSERT INTO job_queue(
16451646
request_tag,
@@ -1651,6 +1652,7 @@ where
16511652
)
16521653
VALUES ($1, $2, $3, $4, $5, $6)
16531654
ON CONFLICT DO NOTHING
1655+
RETURNING job_queue.id
16541656
"#,
16551657
&[
16561658
&request_tag,
@@ -1663,7 +1665,7 @@ where
16631665
)
16641666
.await
16651667
.context("failed to insert benchmark_job")?;
1666-
Ok(())
1668+
Ok(row.get::<_, i32>(0) as u32)
16671669
}
16681670

16691671
async fn get_compile_test_cases_with_measurements(

database/src/pool/sqlite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ impl Connection for SqliteConnection {
13011301
_backend: CodegenBackend,
13021302
_profile: Profile,
13031303
_benchmark_set: u32,
1304-
) -> anyhow::Result<()> {
1304+
) -> anyhow::Result<u32> {
13051305
no_queue_implementation_abort!()
13061306
}
13071307

0 commit comments

Comments
 (0)