@@ -105,7 +105,7 @@ where
105105 update_token_bucket ( & mut self . token_bucket , burst_size, token_rate, timestamp) ;
106106 } ;
107107
108- if let ( Some ( burst_size) , Some ( token_rate) ) = ( config. minburst , config. peakrate ) {
108+ if let ( Some ( burst_size) , Some ( token_rate) ) = ( config. min_burst , config. peak_rate ) {
109109 new_max_size = new_max_size. min ( burst_size) ;
110110 update_token_bucket (
111111 & mut self . peak_token_bucket ,
@@ -191,7 +191,7 @@ where
191191 . map ( |t| t. reserve ( current_size) ) ,
192192 ) {
193193 // None: The token bucket is not present.
194- // Some(None): The token bucket is present, but there is not suffcient token.
194+ // Some(None): The token bucket is present, but there is not sufficient token.
195195 // Some(Some(token)): The token bucket is present, and there is token to be consumed.
196196 ( Some ( None ) , _) | ( _, Some ( None ) ) => {
197197 // We have packets waiting to be sent, yet at least one token bucket is not ready
@@ -221,7 +221,7 @@ where
221221 }
222222 head_packet. into ( )
223223 } else {
224- // Send directly without enque
224+ // Send directly without enqueue
225225 new_packet
226226 }
227227 . expect ( "There should be a packet here" ) ;
@@ -318,7 +318,7 @@ where
318318 derive( Deserialize , Serialize )
319319) ]
320320#[ derive( Debug , Default ) ]
321- /// rate and burst, peakrate and minburst must be provided together
321+ /// rate and burst, peak_rate and min_burst must be provided together
322322pub struct TokenBucketCellConfig {
323323 /// limit of the queue in bytes, default: unlimited
324324 #[ cfg_attr( feature = "serde" , serde( default ) ) ]
@@ -330,11 +330,11 @@ pub struct TokenBucketCellConfig {
330330 /// burst of the bucket in bytes, default: unlimited
331331 pub burst : Option < ByteSize > ,
332332 #[ cfg_attr( feature = "serde" , serde( with = "human_bandwidth::serde" , default ) ) ]
333- /// peakrate of the bucket in bps, default: unlimited
334- pub peakrate : Option < Bandwidth > ,
333+ /// peak_rate of the bucket in bps, default: unlimited
334+ pub peak_rate : Option < Bandwidth > ,
335335 #[ cfg_attr( feature = "serde" , serde( with = "crate::utils::serde::byte" , default ) ) ]
336- /// minburst of the bucket in bytes, default: unlimited
337- pub minburst : Option < ByteSize > ,
336+ /// min_burst of the bucket in bytes, default: unlimited
337+ pub min_burst : Option < ByteSize > ,
338338}
339339
340340impl Clone for TokenBucketCellConfig {
@@ -343,8 +343,8 @@ impl Clone for TokenBucketCellConfig {
343343 limit : self . limit ,
344344 rate : self . rate ,
345345 burst : self . burst ,
346- peakrate : self . peakrate ,
347- minburst : self . minburst ,
346+ peak_rate : self . peak_rate ,
347+ min_burst : self . min_burst ,
348348 }
349349 }
350350}
@@ -360,15 +360,15 @@ impl TokenBucketCellConfig {
360360 limit : L ,
361361 rate : R ,
362362 burst : B ,
363- peakrate : PR ,
364- minburst : MT ,
363+ peak_rate : PR ,
364+ min_burst : MT ,
365365 ) -> Self {
366366 Self {
367367 limit : limit. into ( ) ,
368368 rate : rate. into ( ) ,
369369 burst : burst. into ( ) ,
370- peakrate : peakrate . into ( ) ,
371- minburst : minburst . into ( ) ,
370+ peak_rate : peak_rate . into ( ) ,
371+ min_burst : min_burst . into ( ) ,
372372 }
373373 }
374374}
@@ -385,11 +385,11 @@ fn sanity_check(config: TokenBucketCellConfig) -> Result<TokenBucketCellConfig,
385385 "rate and burst should be provided together" . to_string ( ) ,
386386 ) ) ;
387387 }
388- if ( config. peakrate . is_none ( ) && config. minburst . is_some ( ) )
389- || ( config. peakrate . is_some ( ) && config. minburst . is_none ( ) )
388+ if ( config. peak_rate . is_none ( ) && config. min_burst . is_some ( ) )
389+ || ( config. peak_rate . is_some ( ) && config. min_burst . is_none ( ) )
390390 {
391391 return Err ( Error :: ConfigError (
392- "peakrate and minburst should be provided together" . to_string ( ) ,
392+ "peak_rate and min_burst should be provided together" . to_string ( ) ,
393393 ) ) ;
394394 }
395395 if let Some ( rate) = config. rate {
@@ -406,17 +406,17 @@ fn sanity_check(config: TokenBucketCellConfig) -> Result<TokenBucketCellConfig,
406406 ) ) ;
407407 }
408408 }
409- if let Some ( peakrate ) = config. peakrate {
410- if peakrate . as_bps ( ) == 0 {
409+ if let Some ( peak_rate ) = config. peak_rate {
410+ if peak_rate . as_bps ( ) == 0 {
411411 return Err ( Error :: ConfigError (
412- "peakrate must be greater than 0" . to_string ( ) ,
412+ "peak_rate must be greater than 0" . to_string ( ) ,
413413 ) ) ;
414414 }
415415 }
416- if let Some ( minburst ) = config. minburst {
417- if minburst . as_u64 ( ) == 0 {
416+ if let Some ( min_burst ) = config. min_burst {
417+ if min_burst . as_u64 ( ) == 0 {
418418 return Err ( Error :: ConfigError (
419- "minburst must be greater than 0" . to_string ( ) ,
419+ "min_burst must be greater than 0" . to_string ( ) ,
420420 ) ) ;
421421 }
422422 }
@@ -435,9 +435,9 @@ impl ControlInterface for TokenBucketCellControlInterface {
435435 }
436436}
437437
438- /// Packets whose size is larger than the smaller one of burst and minburst will be dropped before enqueueing.
438+ /// Packets whose size is larger than the smaller one of burst and min_burst will be dropped before enqueueing.
439439/// If the configuration is modified, packets in the queue whose size is larger than the smaller one of
440- /// the new burst and the new minburst will be dropped immediately.
440+ /// the new burst and the new min_burst will be dropped immediately.
441441pub struct TokenBucketCell < P : Packet > {
442442 ingress : Arc < TokenBucketCellIngress < P > > ,
443443 egress : TokenBucketCellEgress < P > ,
@@ -483,8 +483,8 @@ where
483483 limit : L ,
484484 rate : R ,
485485 burst : B ,
486- peakrate : PR ,
487- minburst : MT ,
486+ peak_rate : PR ,
487+ min_burst : MT ,
488488 ) -> Result < TokenBucketCell < P > , Error > {
489489 debug ! ( "New TokenBucketCell" ) ;
490490 let ( rx, tx) = mpsc:: unbounded_channel ( ) ;
@@ -507,7 +507,7 @@ where
507507 } ;
508508
509509 egress. set_config (
510- TokenBucketCellConfig :: new ( limit, rate, burst, peakrate , minburst ) ,
510+ TokenBucketCellConfig :: new ( limit, rate, burst, peak_rate , min_burst ) ,
511511 now,
512512 ) ;
513513
@@ -540,7 +540,7 @@ mod tests {
540540 assert_eq ! ( expected. len( ) , logical. len( ) ) ;
541541 for ( idx, expected_delay) in expected. iter ( ) . enumerate ( ) {
542542 assert_eq ! ( expected_delay, & logical[ idx] ) ;
543- // A larger torlerance is needed in paralleled testing
543+ // A larger tolerance is needed in paralleled testing
544544 assert ! (
545545 expected_delay. saturating_sub( measured[ idx] ) . as_secs_f64( )
546546 <= DELAY_ACCURACY_TOLERANCE * 2E-3
@@ -568,8 +568,8 @@ mod tests {
568568 config. limit ,
569569 config. rate ,
570570 config. burst ,
571- config. peakrate ,
572- config. minburst ,
571+ config. peak_rate ,
572+ config. min_burst ,
573573 ) ?;
574574 let ingress = cell. sender ( ) ;
575575 let mut egress = cell. into_receiver ( ) ;
@@ -654,8 +654,8 @@ mod tests {
654654 config. limit ,
655655 config. rate ,
656656 config. burst ,
657- config. peakrate ,
658- config. minburst ,
657+ config. peak_rate ,
658+ config. min_burst ,
659659 ) ?;
660660 let controller_interface = cell. control_interface . clone ( ) ;
661661 let ingress = cell. sender ( ) ;
@@ -807,9 +807,9 @@ mod tests {
807807
808808 #[ test_log:: test]
809809 fn test_token_bucket_cell_prate_low ( ) -> Result < ( ) , Error > {
810- // test peakrate when peakrate is lower than rate
810+ // test peak_rate when peak_rate is lower than rate
811811 let _span = span ! ( Level :: INFO , "test_token_bucket_cell_prate_low" ) . entered ( ) ;
812- info ! ( "Creating cell with 1024 B burst, 8192 bps rate, 128 B minburst , 4096 bps peakrate and a 1024 bytes limit queue." ) ;
812+ info ! ( "Creating cell with 1024 B burst, 8192 bps rate, 128 B min_burst , 4096 bps peak_rate and a 1024 bytes limit queue." ) ;
813813 let config = TokenBucketCellConfig :: new (
814814 1024 ,
815815 Bandwidth :: from_bps ( 8192 ) ,
@@ -822,7 +822,7 @@ mod tests {
822822 let ( measured_delays, logical_delays) =
823823 get_delays ( 5 , 128 + 14 , config, Duration :: from_millis ( 10 ) ) ?;
824824
825- // In this test, only minburst and peakrate is the bottleneck
825+ // In this test, only min_burst and peak_rate is the bottleneck
826826 //
827827 // Initially, the bucket contains tokens for 8 / 1 packets
828828 // Each packet consumed token that needs 31.25ms / 250ms to refill
@@ -844,9 +844,9 @@ mod tests {
844844
845845 #[ test_log:: test]
846846 fn test_token_bucket_cell_prate_high ( ) -> Result < ( ) , Error > {
847- // test peakrate when peakrate is higher than rate
847+ // test peak_rate when peak_rate is higher than rate
848848 let _span = span ! ( Level :: INFO , "test_token_bucket_cell_prate_high" ) . entered ( ) ;
849- info ! ( "Creating cell with 512 B burst, 4096 bps rate, 256 B minburst , 8192 bps peakrate and a 1024 bytes limit queue." ) ;
849+ info ! ( "Creating cell with 512 B burst, 4096 bps rate, 256 B min_burst , 8192 bps peak_rate and a 1024 bytes limit queue." ) ;
850850 let config = TokenBucketCellConfig :: new (
851851 1024 ,
852852 Bandwidth :: from_bps ( 4096 ) ,
@@ -857,7 +857,7 @@ mod tests {
857857
858858 let ( measured_delays, logical_delays) =
859859 get_delays ( 5 , 128 + 14 , config, Duration :: from_millis ( 10 ) ) ?;
860- // In this test, rate and minburst is the bottleneck
860+ // In this test, rate and min_burst is the bottleneck
861861 //
862862 // Initially, the bucket contains tokens for 4 / 2 packets
863863 // Each packet consumed token that needs 125ms / 62.5ms to refill
0 commit comments