@@ -16,7 +16,7 @@ use docs_rs::utils::{
1616} ;
1717use docs_rs:: {
1818 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 ,
2020} ;
2121use humantime:: Duration ;
2222use once_cell:: sync:: OnceCell ;
@@ -537,12 +537,10 @@ impl DatabaseSubcommand {
537537 }
538538
539539 Self :: UpdateCrateRegistryFields { name } => {
540- let index = ctx. index ( ) ?;
541-
542540 db:: update_crate_data_in_database (
543541 & mut * ctx. conn ( ) ?,
544542 & name,
545- & index . api ( ) . get_crate_data ( & name) ?,
543+ & ctx . registry_api ( ) ? . get_crate_data ( & name) ?,
546544 ) ?;
547545 }
548546
@@ -719,6 +717,7 @@ struct BinContext {
719717 service_metrics : OnceCell < Arc < ServiceMetrics > > ,
720718 instance_metrics : OnceCell < Arc < InstanceMetrics > > ,
721719 index : OnceCell < Arc < Index > > ,
720+ registry_api : OnceCell < Arc < RegistryApi > > ,
722721 repository_stats_updater : OnceCell < Arc < RepositoryStatsUpdater > > ,
723722 runtime : OnceCell < Arc < Runtime > > ,
724723}
@@ -734,6 +733,7 @@ impl BinContext {
734733 service_metrics : OnceCell :: new ( ) ,
735734 instance_metrics : OnceCell :: new ( ) ,
736735 index : OnceCell :: new ( ) ,
736+ registry_api : OnceCell :: new ( ) ,
737737 repository_stats_updater : OnceCell :: new ( ) ,
738738 runtime : OnceCell :: new ( ) ,
739739 }
@@ -783,11 +783,15 @@ impl Context for BinContext {
783783 let config = self . config( ) ?;
784784 let path = config. registry_index_path. clone( ) ;
785785 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)
787787 } else {
788- Index :: new( path, config . crates_io_api_call_retries )
788+ Index :: new( path)
789789 } ?
790790 } ;
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+ } ;
791795 fn repository_stats_updater( self ) -> RepositoryStatsUpdater = {
792796 let config = self . config( ) ?;
793797 let pool = self . pool( ) ?;
0 commit comments