@@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize};
1818use tracing:: debug;
1919
2020use crate :: {
21- downloader:: Downloader ,
21+ downloader:: { ConcurrencyLimits , Downloader , RetryConfig } ,
2222 provider:: EventSender ,
2323 store:: GcConfig ,
2424 util:: {
@@ -148,6 +148,8 @@ pub struct Builder<S> {
148148 store : S ,
149149 events : Option < EventSender > ,
150150 rt : Option < LocalPoolHandle > ,
151+ concurrency_limits : Option < ConcurrencyLimits > ,
152+ retry_config : Option < RetryConfig > ,
151153}
152154
153155impl < S : crate :: store:: Store > Builder < S > {
@@ -157,20 +159,38 @@ impl<S: crate::store::Store> Builder<S> {
157159 self
158160 }
159161
160- /// Set a custom `LocalPoolHandle` to use.
162+ /// Set a custom [ `LocalPoolHandle`] to use.
161163 pub fn local_pool ( mut self , rt : LocalPoolHandle ) -> Self {
162164 self . rt = Some ( rt) ;
163165 self
164166 }
165167
168+ /// Set custom [`ConcurrencyLimits`] to use.
169+ pub fn concurrency_limits ( mut self , concurrency_limits : ConcurrencyLimits ) -> Self {
170+ self . concurrency_limits = Some ( concurrency_limits) ;
171+ self
172+ }
173+
174+ /// Set a custom [`RetryConfig`] to use.
175+ pub fn retry_config ( mut self , retry_config : RetryConfig ) -> Self {
176+ self . retry_config = Some ( retry_config) ;
177+ self
178+ }
179+
166180 /// Build the Blobs protocol handler.
167181 /// You need to provide a the endpoint.
168182 pub fn build ( self , endpoint : & Endpoint ) -> Blobs < S > {
169183 let rt = self
170184 . rt
171185 . map ( Rt :: Handle )
172186 . unwrap_or_else ( || Rt :: Owned ( LocalPool :: default ( ) ) ) ;
173- let downloader = Downloader :: new ( self . store . clone ( ) , endpoint. clone ( ) , rt. clone ( ) ) ;
187+ let downloader = Downloader :: with_config (
188+ self . store . clone ( ) ,
189+ endpoint. clone ( ) ,
190+ rt. clone ( ) ,
191+ self . concurrency_limits . unwrap_or_default ( ) ,
192+ self . retry_config . unwrap_or_default ( ) ,
193+ ) ;
174194 Blobs :: new (
175195 self . store ,
176196 rt,
@@ -188,6 +208,8 @@ impl<S> Blobs<S> {
188208 store,
189209 events : None ,
190210 rt : None ,
211+ concurrency_limits : None ,
212+ retry_config : None ,
191213 }
192214 }
193215}
0 commit comments