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