Skip to content

Commit e4698c5

Browse files
refactor: rename global client to repo loader
1 parent e99f1ee commit e4698c5

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/bors/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ use arc_swap::ArcSwap;
33
use crate::{bors::command::CommandParser, database::DbClient, github::GithubRepoName};
44
use std::{collections::HashMap, sync::Arc};
55

6-
use super::{GlobalClient, RepositoryClient, RepositoryState};
6+
use super::{RepositoryClient, RepositoryLoader, RepositoryState};
77

88
pub struct BorsContext<Client: RepositoryClient> {
99
pub parser: CommandParser,
1010
pub db: Arc<dyn DbClient>,
11-
pub global_client: Arc<dyn GlobalClient<Client>>,
11+
pub repository_loader: Arc<dyn RepositoryLoader<Client>>,
1212
pub repositories: Arc<ArcSwap<HashMap<GithubRepoName, Arc<RepositoryState<Client>>>>>,
1313
}
1414

1515
impl<Client: RepositoryClient> BorsContext<Client> {
1616
pub async fn new(
1717
parser: CommandParser,
1818
db: Arc<dyn DbClient>,
19-
global_client: Arc<dyn GlobalClient<Client>>,
19+
global_client: Arc<dyn RepositoryLoader<Client>>,
2020
) -> anyhow::Result<Self> {
2121
// this unwrap is making me nervous, but if lhe repos loading
2222
// fails we might as well restart the bot
@@ -25,7 +25,7 @@ impl<Client: RepositoryClient> BorsContext<Client> {
2525
Ok(Self {
2626
parser,
2727
db,
28-
global_client,
28+
repository_loader: global_client,
2929
repositories,
3030
})
3131
}

src/bors/handlers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub async fn handle_bors_global_event<Client: RepositoryClient>(
123123
BorsGlobalEvent::InstallationsChanged => {
124124
let span = tracing::info_span!("Repository reload").entered();
125125

126-
match ctx.global_client.load_repositories().await {
126+
match ctx.repository_loader.load_repositories().await {
127127
Ok(repos) => {
128128
ctx.repositories.store(Arc::new(repos));
129129
}

src/bors/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub trait RepositoryClient: Send + Sync {
7474
/// Temporary trait to sastify the test mocking.
7575
/// TODO: Remove this trait once we move to mock REST API call.
7676
#[async_trait]
77-
pub trait GlobalClient<Client: RepositoryClient>: Send + Sync {
77+
pub trait RepositoryLoader<Client: RepositoryClient>: Send + Sync {
7878
/// Load state of repositories.
7979
async fn load_repositories(
8080
&self,

src/github/api/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tracing::log;
99

1010
use crate::bors::event::PullRequestComment;
1111
use crate::bors::{
12-
CheckSuite, CheckSuiteStatus, Comment, GlobalClient, RepositoryClient, RepositoryState,
12+
CheckSuite, CheckSuiteStatus, Comment, RepositoryClient, RepositoryLoader, RepositoryState,
1313
};
1414
use crate::config::{RepositoryConfig, CONFIG_FILE_PATH};
1515
use crate::github::api::base_github_html_url;
@@ -271,7 +271,7 @@ impl RepositoryClient for GithubRepositoryClient {
271271
}
272272

273273
#[async_trait]
274-
impl GlobalClient<GithubRepositoryClient> for Octocrab {
274+
impl RepositoryLoader<GithubRepositoryClient> for Octocrab {
275275
async fn load_repositories(
276276
&self,
277277
) -> anyhow::Result<HashMap<GithubRepoName, Arc<RepositoryState<GithubRepositoryClient>>>> {

src/tests/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::bors::{
1919
handle_bors_global_event, handle_bors_repository_event, BorsContext, CheckSuite, CommandParser,
2020
Comment, RepositoryState,
2121
};
22-
use crate::bors::{GlobalClient, RepositoryClient};
22+
use crate::bors::{RepositoryClient, RepositoryLoader};
2323
use crate::config::RepositoryConfig;
2424
use crate::database::{DbClient, WorkflowStatus};
2525
use crate::github::{
@@ -260,7 +260,7 @@ impl ClientBuilder {
260260
}
261261

262262
#[async_trait]
263-
impl GlobalClient<Arc<TestRepositoryClient>> for Arc<TestRepositoryClient> {
263+
impl RepositoryLoader<Arc<TestRepositoryClient>> for Arc<TestRepositoryClient> {
264264
async fn load_repositories(
265265
&self,
266266
) -> anyhow::Result<HashMap<GithubRepoName, Arc<TestRepositoryState>>> {

0 commit comments

Comments
 (0)