Skip to content

Commit a5eb3ac

Browse files
authored
Merge pull request #2271 from Kobzol/sqlite-queue
Allow running the website with SQLite
2 parents 406c4fa + ec3e13d commit a5eb3ac

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

database/src/pool.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ pub trait Connection: Send + Sync {
2222

2323
async fn load_index(&mut self) -> Index;
2424

25+
/// Returns true if the given database backend supports the job queue system.
26+
fn supports_job_queue(&self) -> bool;
27+
2528
/// None means that the caller doesn't know; it should be left alone if
2629
/// known or set to false if unknown.
2730
async fn record_compile_benchmark(

database/src/pool/postgres.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,10 @@ where
23352335
.await?;
23362336
Ok(())
23372337
}
2338+
2339+
fn supports_job_queue(&self) -> bool {
2340+
true
2341+
}
23382342
}
23392343

23402344
fn row_to_benchmark_request(row: &Row, row_offset: Option<usize>) -> BenchmarkRequest {

database/src/pool/sqlite.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,9 @@ impl Connection for SqliteConnection {
13031303
}
13041304

13051305
async fn load_benchmark_request_index(&self) -> anyhow::Result<BenchmarkRequestIndex> {
1306-
no_queue_implementation_abort!()
1306+
Ok(BenchmarkRequestIndex {
1307+
all: Default::default(),
1308+
})
13071309
}
13081310

13091311
async fn load_pending_benchmark_requests(&self) -> anyhow::Result<PendingBenchmarkRequests> {
@@ -1438,6 +1440,10 @@ impl Connection for SqliteConnection {
14381440
) -> anyhow::Result<Vec<BenchmarkRequestWithErrors>> {
14391441
no_queue_implementation_abort!()
14401442
}
1443+
1444+
fn supports_job_queue(&self) -> bool {
1445+
false
1446+
}
14411447
}
14421448

14431449
fn parse_artifact_id(ty: &str, sha: &str, date: Option<i64>) -> ArtifactId {

site/src/job_queue/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ async fn process_benchmark_requests(
366366
/// finishes completed benchmark requests.
367367
async fn perform_queue_tick(ctxt: &SiteCtxt) -> anyhow::Result<()> {
368368
let mut conn = ctxt.conn().await;
369+
if !conn.supports_job_queue() {
370+
return Ok(());
371+
}
369372

370373
let index = ctxt.known_benchmark_requests.load();
371374

0 commit comments

Comments
 (0)