@@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize};
18
18
use tracing:: debug;
19
19
20
20
use crate :: {
21
- downloader:: Downloader ,
21
+ downloader:: { ConcurrencyLimits , Downloader , RetryConfig } ,
22
22
provider:: EventSender ,
23
23
store:: GcConfig ,
24
24
util:: {
@@ -148,6 +148,8 @@ pub struct Builder<S> {
148
148
store : S ,
149
149
events : Option < EventSender > ,
150
150
rt : Option < LocalPoolHandle > ,
151
+ concurrency_limits : Option < ConcurrencyLimits > ,
152
+ retry_config : Option < RetryConfig > ,
151
153
}
152
154
153
155
impl < S : crate :: store:: Store > Builder < S > {
@@ -157,20 +159,38 @@ impl<S: crate::store::Store> Builder<S> {
157
159
self
158
160
}
159
161
160
- /// Set a custom `LocalPoolHandle` to use.
162
+ /// Set a custom [ `LocalPoolHandle`] to use.
161
163
pub fn local_pool ( mut self , rt : LocalPoolHandle ) -> Self {
162
164
self . rt = Some ( rt) ;
163
165
self
164
166
}
165
167
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
+
166
180
/// Build the Blobs protocol handler.
167
181
/// You need to provide a the endpoint.
168
182
pub fn build ( self , endpoint : & Endpoint ) -> Blobs < S > {
169
183
let rt = self
170
184
. rt
171
185
. map ( Rt :: Handle )
172
186
. 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
+ ) ;
174
194
Blobs :: new (
175
195
self . store ,
176
196
rt,
@@ -188,6 +208,8 @@ impl<S> Blobs<S> {
188
208
store,
189
209
events : None ,
190
210
rt : None ,
211
+ concurrency_limits : None ,
212
+ retry_config : None ,
191
213
}
192
214
}
193
215
}
0 commit comments