@@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize};
1818use tracing:: debug;
1919
2020use crate :: {
21- downloader:: Downloader ,
21+ downloader:: { self , Downloader } ,
2222 provider:: EventSender ,
2323 store:: GcConfig ,
2424 util:: {
@@ -142,11 +142,18 @@ impl BlobBatches {
142142 }
143143}
144144
145+ #[ derive( Debug , Default ) ]
146+ pub struct DownloaderConfig {
147+ pub concurrency : downloader:: ConcurrencyLimits ,
148+ pub retry : downloader:: RetryConfig ,
149+ }
150+
145151/// Builder for the Blobs protocol handler
146152#[ derive( Debug ) ]
147153pub struct Builder < S > {
148154 store : S ,
149155 events : Option < EventSender > ,
156+ downloader : Option < DownloaderConfig > ,
150157 rt : Option < LocalPoolHandle > ,
151158}
152159
@@ -163,14 +170,27 @@ impl<S: crate::store::Store> Builder<S> {
163170 self
164171 }
165172
173+ /// Set a custom downloader configuration.
174+ pub fn downloader ( mut self , config : DownloaderConfig ) -> Self {
175+ self . downloader = Some ( config) ;
176+ self
177+ }
178+
166179 /// Build the Blobs protocol handler.
167180 /// You need to provide a the endpoint.
168181 pub fn build ( self , endpoint : & Endpoint ) -> Blobs < S > {
169182 let rt = self
170183 . rt
171184 . map ( Rt :: Handle )
172185 . unwrap_or_else ( || Rt :: Owned ( LocalPool :: default ( ) ) ) ;
173- let downloader = Downloader :: new ( self . store . clone ( ) , endpoint. clone ( ) , rt. clone ( ) ) ;
186+ let DownloaderConfig { concurrency, retry } = self . downloader . unwrap_or_default ( ) ;
187+ let downloader = Downloader :: with_config (
188+ self . store . clone ( ) ,
189+ endpoint. clone ( ) ,
190+ rt. clone ( ) ,
191+ concurrency,
192+ retry,
193+ ) ;
174194 Blobs :: new (
175195 self . store ,
176196 rt,
@@ -187,6 +207,7 @@ impl<S> Blobs<S> {
187207 Builder {
188208 store,
189209 events : None ,
210+ downloader : None ,
190211 rt : None ,
191212 }
192213 }
0 commit comments