@@ -16,7 +16,7 @@ use docs_rs::utils::{
16
16
} ;
17
17
use docs_rs:: {
18
18
start_background_metrics_webserver, start_web_server, AsyncStorage , BuildQueue , Config ,
19
- Context , Index , InstanceMetrics , PackageKind , RustwideBuilder , ServiceMetrics , Storage ,
19
+ Context , Index , RegistryApi , InstanceMetrics , PackageKind , RustwideBuilder , ServiceMetrics , Storage ,
20
20
} ;
21
21
use humantime:: Duration ;
22
22
use once_cell:: sync:: OnceCell ;
@@ -537,12 +537,10 @@ impl DatabaseSubcommand {
537
537
}
538
538
539
539
Self :: UpdateCrateRegistryFields { name } => {
540
- let index = ctx. index ( ) ?;
541
-
542
540
db:: update_crate_data_in_database (
543
541
& mut * ctx. conn ( ) ?,
544
542
& name,
545
- & index . api ( ) . get_crate_data ( & name) ?,
543
+ & ctx . registry_api ( ) ? . get_crate_data ( & name) ?,
546
544
) ?;
547
545
}
548
546
@@ -719,6 +717,7 @@ struct BinContext {
719
717
service_metrics : OnceCell < Arc < ServiceMetrics > > ,
720
718
instance_metrics : OnceCell < Arc < InstanceMetrics > > ,
721
719
index : OnceCell < Arc < Index > > ,
720
+ registry_api : OnceCell < Arc < RegistryApi > > ,
722
721
repository_stats_updater : OnceCell < Arc < RepositoryStatsUpdater > > ,
723
722
runtime : OnceCell < Arc < Runtime > > ,
724
723
}
@@ -734,6 +733,7 @@ impl BinContext {
734
733
service_metrics : OnceCell :: new ( ) ,
735
734
instance_metrics : OnceCell :: new ( ) ,
736
735
index : OnceCell :: new ( ) ,
736
+ registry_api : OnceCell :: new ( ) ,
737
737
repository_stats_updater : OnceCell :: new ( ) ,
738
738
runtime : OnceCell :: new ( ) ,
739
739
}
@@ -783,11 +783,15 @@ impl Context for BinContext {
783
783
let config = self . config( ) ?;
784
784
let path = config. registry_index_path. clone( ) ;
785
785
if let Some ( registry_url) = config. registry_url. clone( ) {
786
- Index :: from_url( path, registry_url, config . crates_io_api_call_retries )
786
+ Index :: from_url( path, registry_url)
787
787
} else {
788
- Index :: new( path, config . crates_io_api_call_retries )
788
+ Index :: new( path)
789
789
} ?
790
790
} ;
791
+ fn registry_api( self ) -> RegistryApi = {
792
+ let config = self . config( ) ?;
793
+ RegistryApi :: new( config. registry_api_host. clone( ) , config. crates_io_api_call_retries) ?
794
+ } ;
791
795
fn repository_stats_updater( self ) -> RepositoryStatsUpdater = {
792
796
let config = self . config( ) ?;
793
797
let pool = self . pool( ) ?;
0 commit comments