@@ -206,6 +206,7 @@ pub trait MakeConnection: Send + Sync + 'static {
206206 timeout : Option < Duration > ,
207207 max_total_response_size : u64 ,
208208 max_concurrent_requests : u64 ,
209+ disable_intelligent_throttling : bool ,
209210 ) -> MakeThrottledConnection < Self >
210211 where
211212 Self : Sized ,
@@ -216,6 +217,7 @@ pub trait MakeConnection: Send + Sync + 'static {
216217 timeout,
217218 max_total_response_size,
218219 max_concurrent_requests,
220+ disable_intelligent_throttling,
219221 )
220222 }
221223
@@ -281,6 +283,7 @@ pub struct MakeThrottledConnection<F> {
281283 max_total_response_size : u64 ,
282284 waiters : AtomicUsize ,
283285 max_concurrent_requests : u64 ,
286+ disable_intelligent_throttling : bool ,
284287}
285288
286289impl < F > MakeThrottledConnection < F > {
@@ -290,6 +293,7 @@ impl<F> MakeThrottledConnection<F> {
290293 timeout : Option < Duration > ,
291294 max_total_response_size : u64 ,
292295 max_concurrent_requests : u64 ,
296+ disable_intelligent_throttling : bool ,
293297 ) -> Self {
294298 Self {
295299 semaphore,
@@ -298,12 +302,16 @@ impl<F> MakeThrottledConnection<F> {
298302 max_total_response_size,
299303 waiters : AtomicUsize :: new ( 0 ) ,
300304 max_concurrent_requests,
305+ disable_intelligent_throttling,
301306 }
302307 }
303308
304309 // How many units should be acquired from the semaphore,
305310 // depending on current memory pressure.
306311 fn units_to_take ( & self ) -> u32 {
312+ if self . disable_intelligent_throttling {
313+ return 1 ;
314+ }
307315 let total_response_size = crate :: query_result_builder:: TOTAL_RESPONSE_SIZE
308316 . load ( std:: sync:: atomic:: Ordering :: Relaxed ) as u64 ;
309317 if total_response_size * 2 > self . max_total_response_size {
@@ -522,6 +530,7 @@ pub mod test {
522530 Some ( Duration :: from_millis ( 100 ) ) ,
523531 u64:: MAX ,
524532 u64:: MAX ,
533+ false ,
525534 ) ;
526535
527536 let mut conns = Vec :: with_capacity ( 10 ) ;
0 commit comments