@@ -141,7 +141,7 @@ pub enum GetOutput<N> {
141
141
}
142
142
143
143
/// Concurrency limits for the [`Downloader`].
144
- #[ derive( Debug ) ]
144
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
145
145
pub struct ConcurrencyLimits {
146
146
/// Maximum number of requests the service performs concurrently.
147
147
pub max_concurrent_requests : usize ,
@@ -193,7 +193,7 @@ impl ConcurrencyLimits {
193
193
}
194
194
195
195
/// Configuration for retry behavior of the [`Downloader`].
196
- #[ derive( Debug ) ]
196
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
197
197
pub struct RetryConfig {
198
198
/// Maximum number of retry attempts for a node that failed to dial or failed with IO errors.
199
199
pub max_retries_per_node : u32 ,
@@ -325,6 +325,15 @@ impl Future for DownloadHandle {
325
325
}
326
326
}
327
327
328
+ /// All numerical config options for the downloader.
329
+ #[ derive( Debug , Default , Clone , Copy , PartialEq , Eq ) ]
330
+ pub struct Config {
331
+ /// Concurrency limits for the downloader.
332
+ pub concurrency : ConcurrencyLimits ,
333
+ /// Retry configuration for the downloader.
334
+ pub retry : RetryConfig ,
335
+ }
336
+
328
337
/// Handle for the download services.
329
338
#[ derive( Clone , Debug ) ]
330
339
pub struct Downloader {
@@ -374,6 +383,15 @@ impl Downloader {
374
383
}
375
384
}
376
385
386
+ /// Get the current configuration.
387
+ pub async fn get_config ( & self ) -> anyhow:: Result < Config > {
388
+ let ( tx, rx) = oneshot:: channel ( ) ;
389
+ let msg = Message :: GetConfig { tx } ;
390
+ self . msg_tx . send ( msg) . await ?;
391
+ let config = rx. await ?;
392
+ Ok ( config)
393
+ }
394
+
377
395
/// Queue a download.
378
396
pub async fn queue ( & self , request : DownloadRequest ) -> DownloadHandle {
379
397
let kind = request. kind ;
@@ -441,6 +459,11 @@ enum Message {
441
459
/// Cancel an intent. The associated request will be cancelled when the last intent is
442
460
/// cancelled.
443
461
CancelIntent { id : IntentId , kind : DownloadKind } ,
462
+ /// Get the config
463
+ GetConfig {
464
+ #[ debug( skip) ]
465
+ tx : oneshot:: Sender < Config > ,
466
+ } ,
444
467
}
445
468
446
469
#[ derive( derive_more:: Debug ) ]
@@ -668,6 +691,13 @@ impl<G: Getter<Connection = D::Connection>, D: DialerT> Service<G, D> {
668
691
self . queue . unpark_hash ( hash) ;
669
692
}
670
693
}
694
+ Message :: GetConfig { tx } => {
695
+ let config = Config {
696
+ concurrency : self . concurrency_limits ,
697
+ retry : self . retry_config ,
698
+ } ;
699
+ tx. send ( config) . ok ( ) ;
700
+ }
671
701
}
672
702
}
673
703
0 commit comments