1+ use std:: pin:: Pin ;
12use std:: sync:: Arc ;
23use std:: time:: Duration ;
34
@@ -15,13 +16,17 @@ pub async fn refresh_repository(
1516 db : Arc < PgDbClient > ,
1617 team_api_client : & TeamApiClient ,
1718) -> anyhow:: Result < ( ) > {
18- let repo = repo. as_ref ( ) ;
19- if let ( Ok ( _) , _, Ok ( _) , Ok ( _) ) = tokio:: join!(
20- cancel_timed_out_builds( repo, db. as_ref( ) ) ,
21- reload_permission( repo, team_api_client) ,
22- reload_config( repo) ,
23- reload_unknown_mergeable_prs( repo, db. as_ref( ) )
24- ) {
19+ let repo_ref = repo. as_ref ( ) ;
20+ let db_ref = db. as_ref ( ) ;
21+ let tasks: Vec < Pin < Box < dyn Future < Output = anyhow:: Result < ( ) > > + Send > > > = vec ! [
22+ Box :: pin( cancel_timed_out_builds( repo_ref, db_ref) ) ,
23+ Box :: pin( reload_permission( repo_ref, team_api_client) ) ,
24+ Box :: pin( reload_config( repo_ref) ) ,
25+ Box :: pin( reload_unknown_mergeable_prs( repo_ref, db_ref) ) ,
26+ ] ;
27+ let results = futures:: future:: join_all ( tasks) . await ;
28+
29+ if results. into_iter ( ) . all ( |res| res. is_ok ( ) ) {
2530 Ok ( ( ) )
2631 } else {
2732 tracing:: error!( "Failed to refresh repository" ) ;
0 commit comments