Skip to content

Commit 246129c

Browse files
committed
Add possibility to skip workqueue loading
1 parent 71f8d2e commit 246129c

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ The general overview of what you will need to do:
5050
6. Add a `triagebot.toml` file to the main branch of your GitHub repo with whichever services you want to try out.
5151
7. Try interacting with your repo, such as issuing `@rustbot` commands or interacting with PRs and issues (depending on which services you enabled in `triagebot.toml`). Watch the logs from the server to see what's going on.
5252

53+
#### Skipping workqueue loading
54+
55+
When triagebot starts, it eagerly loads the pull request workqueue for the `rust-lang/rust` repository, which can take up ~10-15 seconds. To disable this, for faster local experiments, pass the `SKIP_WORKQUEUE=1` environment variable to triagebot.
56+
5357
### Configure a database
5458

5559
To use Postgres, you will need to install it and configure it:

src/main.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,23 +253,37 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
253253
.build()
254254
.expect("Failed to build octograb.");
255255

256+
// Loading the workqueue takes ~10-15s, and it's annoying for local rebuilds.
257+
// Allow users to opt out of it.
258+
let skip_loading_workqueue = env::var("SKIP_WORKQUEUE")
259+
.ok()
260+
.map(|v| v == "1")
261+
.unwrap_or(false);
262+
256263
// Load the initial workqueue state from GitHub
257264
// In case this fails, we do not want to block triagebot, instead
258265
// we use an empty workqueue and let it be updated later through
259266
// webhooks and the `PullRequestAssignmentUpdate` cron job.
260-
tracing::info!("Loading reviewer workqueue for rust-lang/rust");
261-
let workqueue = match tokio::time::timeout(Duration::from_secs(60), load_workqueue(&oc)).await {
262-
Ok(Ok(workqueue)) => workqueue,
263-
Ok(Err(error)) => {
264-
tracing::error!("Cannot load initial workqueue: {error:?}");
265-
ReviewerWorkqueue::default()
266-
}
267-
Err(_) => {
268-
tracing::error!("Cannot load initial workqueue, timeouted after a minute");
269-
ReviewerWorkqueue::default()
270-
}
267+
let workqueue = if skip_loading_workqueue {
268+
tracing::warn!("Skipping workqueue loading");
269+
ReviewerWorkqueue::default()
270+
} else {
271+
tracing::info!("Loading reviewer workqueue for rust-lang/rust");
272+
let workqueue =
273+
match tokio::time::timeout(Duration::from_secs(60), load_workqueue(&oc)).await {
274+
Ok(Ok(workqueue)) => workqueue,
275+
Ok(Err(error)) => {
276+
tracing::error!("Cannot load initial workqueue: {error:?}");
277+
ReviewerWorkqueue::default()
278+
}
279+
Err(_) => {
280+
tracing::error!("Cannot load initial workqueue, timeouted after a minute");
281+
ReviewerWorkqueue::default()
282+
}
283+
};
284+
tracing::info!("Workqueue loaded");
285+
workqueue
271286
};
272-
tracing::info!("Workqueue loaded");
273287

274288
// Only run the migrations after the workqueue has been loaded, immediately
275289
// before starting the HTTP server.

0 commit comments

Comments
 (0)