@@ -206,6 +206,7 @@ pub trait MakeConnection: Send + Sync + 'static {
206
206
timeout : Option < Duration > ,
207
207
max_total_response_size : u64 ,
208
208
max_concurrent_requests : u64 ,
209
+ disable_intelligent_throttling : bool ,
209
210
) -> MakeThrottledConnection < Self >
210
211
where
211
212
Self : Sized ,
@@ -216,6 +217,7 @@ pub trait MakeConnection: Send + Sync + 'static {
216
217
timeout,
217
218
max_total_response_size,
218
219
max_concurrent_requests,
220
+ disable_intelligent_throttling,
219
221
)
220
222
}
221
223
@@ -281,6 +283,7 @@ pub struct MakeThrottledConnection<F> {
281
283
max_total_response_size : u64 ,
282
284
waiters : AtomicUsize ,
283
285
max_concurrent_requests : u64 ,
286
+ disable_intelligent_throttling : bool ,
284
287
}
285
288
286
289
impl < F > MakeThrottledConnection < F > {
@@ -290,6 +293,7 @@ impl<F> MakeThrottledConnection<F> {
290
293
timeout : Option < Duration > ,
291
294
max_total_response_size : u64 ,
292
295
max_concurrent_requests : u64 ,
296
+ disable_intelligent_throttling : bool ,
293
297
) -> Self {
294
298
Self {
295
299
semaphore,
@@ -298,12 +302,16 @@ impl<F> MakeThrottledConnection<F> {
298
302
max_total_response_size,
299
303
waiters : AtomicUsize :: new ( 0 ) ,
300
304
max_concurrent_requests,
305
+ disable_intelligent_throttling,
301
306
}
302
307
}
303
308
304
309
// How many units should be acquired from the semaphore,
305
310
// depending on current memory pressure.
306
311
fn units_to_take ( & self ) -> u32 {
312
+ if self . disable_intelligent_throttling {
313
+ return 1 ;
314
+ }
307
315
let total_response_size = crate :: query_result_builder:: TOTAL_RESPONSE_SIZE
308
316
. load ( std:: sync:: atomic:: Ordering :: Relaxed ) as u64 ;
309
317
if total_response_size * 2 > self . max_total_response_size {
@@ -522,6 +530,7 @@ pub mod test {
522
530
Some ( Duration :: from_millis ( 100 ) ) ,
523
531
u64:: MAX ,
524
532
u64:: MAX ,
533
+ false ,
525
534
) ;
526
535
527
536
let mut conns = Vec :: with_capacity ( 10 ) ;
0 commit comments