@@ -16,7 +16,8 @@ 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 , InstanceMetrics , PackageKind , RegistryApi , RustwideBuilder , ServiceMetrics ,
20+ Storage ,
2021} ;
2122use humantime:: Duration ;
2223use once_cell:: sync:: OnceCell ;
@@ -537,12 +538,10 @@ impl DatabaseSubcommand {
537538 }
538539
539540 Self :: UpdateCrateRegistryFields { name } => {
540- let index = ctx. index ( ) ?;
541-
542541 db:: update_crate_data_in_database (
543542 & mut * ctx. conn ( ) ?,
544543 & name,
545- & index . api ( ) . get_crate_data ( & name) ?,
544+ & ctx . registry_api ( ) ? . get_crate_data ( & name) ?,
546545 ) ?;
547546 }
548547
@@ -719,6 +718,7 @@ struct BinContext {
719718 service_metrics : OnceCell < Arc < ServiceMetrics > > ,
720719 instance_metrics : OnceCell < Arc < InstanceMetrics > > ,
721720 index : OnceCell < Arc < Index > > ,
721+ registry_api : OnceCell < Arc < RegistryApi > > ,
722722 repository_stats_updater : OnceCell < Arc < RepositoryStatsUpdater > > ,
723723 runtime : OnceCell < Arc < Runtime > > ,
724724}
@@ -734,6 +734,7 @@ impl BinContext {
734734 service_metrics : OnceCell :: new ( ) ,
735735 instance_metrics : OnceCell :: new ( ) ,
736736 index : OnceCell :: new ( ) ,
737+ registry_api : OnceCell :: new ( ) ,
737738 repository_stats_updater : OnceCell :: new ( ) ,
738739 runtime : OnceCell :: new ( ) ,
739740 }
@@ -783,11 +784,15 @@ impl Context for BinContext {
783784 let config = self . config( ) ?;
784785 let path = config. registry_index_path. clone( ) ;
785786 if let Some ( registry_url) = config. registry_url. clone( ) {
786- Index :: from_url( path, registry_url, config . crates_io_api_call_retries )
787+ Index :: from_url( path, registry_url)
787788 } else {
788- Index :: new( path, config . crates_io_api_call_retries )
789+ Index :: new( path)
789790 } ?
790791 } ;
792+ fn registry_api( self ) -> RegistryApi = {
793+ let config = self . config( ) ?;
794+ RegistryApi :: new( config. registry_api_host. clone( ) , config. crates_io_api_call_retries) ?
795+ } ;
791796 fn repository_stats_updater( self ) -> RepositoryStatsUpdater = {
792797 let config = self . config( ) ?;
793798 let pool = self . pool( ) ?;
0 commit comments