Skip to content

Commit e4d1bc2

Browse files
committed
Clone the existing GitHub client instead of creating a new one
The client is already cloneable and should reuse the connection pool.
1 parent cc3c50b commit e4d1bc2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/handlers/merge_conflict.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ async fn handle_branch_push(
9191
let repo = push.repository.clone();
9292
let db = ctx.db.get().await;
9393
// Spawn since this can trigger a lot of work.
94+
let gh = ctx.github.clone();
9495
tokio::task::spawn(async move {
9596
// See module note about locking.
96-
let gh = GithubClient::new_from_env();
9797
if let Err(e) = scan_prs(&gh, db, &config, repo, &branch_name, &push_sha).await {
9898
log::error!("failed to scan PRs for merge conflicts: {e:?}");
9999
}
@@ -118,10 +118,10 @@ async fn handle_pr(
118118
let pr_number = issue.number;
119119
let db = ctx.db.get().await;
120120
let config = config.clone();
121+
let gh = ctx.github.clone();
121122
tokio::task::spawn(async move {
122123
// See module note about locking.
123124
tokio::time::sleep(UNKNOWN_RESCAN_DELAY).await;
124-
let gh = GithubClient::new_from_env();
125125
if let Err(e) = rescan_pr(&gh, db, &config, repo, pr_number).await {
126126
log::error!("failed to rescan PR for merge conflicts: {e:?}");
127127
}
@@ -210,10 +210,10 @@ async fn scan_prs(
210210
}
211211
if !unknowns.is_empty() {
212212
let config = config.clone();
213+
let gh = gh.clone();
213214
tokio::task::spawn(async move {
214215
// See module note about locking.
215216
tokio::time::sleep(UNKNOWN_RESCAN_DELAY).await;
216-
let gh = GithubClient::new_from_env();
217217
// NOTE: The `possibly` here is even less likely to be correct due
218218
// to the risk that another push happened while we were waiting.
219219
// May want to consider changing it to `None` if it regularly

0 commit comments

Comments
 (0)