@@ -419,6 +419,7 @@ fn parsing() {
419419 inodes_max: 64
420420 hotreload: false
421421 scan_interval: 60
422+ rate_limit: 50000
422423 "# ,
423424 FactConfig {
424425 paths : Some ( vec ! [ PathBuf :: from( "/etc" ) ] ) ,
@@ -449,7 +450,7 @@ fn parsing() {
449450 } ,
450451 hotreload : Some ( false ) ,
451452 scan_interval : Some ( Duration :: from_secs ( 60 ) ) ,
452- rate_limit : None ,
453+ rate_limit : Some ( 50000 ) ,
453454 } ,
454455 ) ,
455456 ] ;
@@ -780,6 +781,15 @@ paths:
780781 "scan_interval: -128.5" ,
781782 "invalid scan_interval: Real(\" -128.5\" )" ,
782783 ) ,
784+ (
785+ "rate_limit: true" ,
786+ "rate_limit field has incorrect type: Boolean(true)" ,
787+ ) ,
788+ (
789+ "rate_limit: 1000.0" ,
790+ "rate_limit field has incorrect type: Real(\" 1000.0\" )" ,
791+ ) ,
792+ ( "rate_limit: -1000" , "invalid rate_limit: -1000" ) ,
783793 ( "unknown:" , "Invalid field 'unknown' with value: Null" ) ,
784794 ] ;
785795 for ( input, expected) in tests {
@@ -1571,6 +1581,25 @@ fn update() {
15711581 ..Default :: default ( )
15721582 } ,
15731583 ) ,
1584+ (
1585+ "rate_limit: 1000" ,
1586+ FactConfig :: default ( ) ,
1587+ FactConfig {
1588+ rate_limit : Some ( 1000 ) ,
1589+ ..Default :: default ( )
1590+ } ,
1591+ ) ,
1592+ (
1593+ "rate_limit: 1000" ,
1594+ FactConfig {
1595+ rate_limit : Some ( 50000 ) ,
1596+ ..Default :: default ( )
1597+ } ,
1598+ FactConfig {
1599+ rate_limit : Some ( 1000 ) ,
1600+ ..Default :: default ( )
1601+ } ,
1602+ ) ,
15741603 (
15751604 r#"
15761605 paths:
@@ -1597,6 +1626,7 @@ fn update() {
15971626 inodes_max: 8192
15981627 hotreload: false
15991628 scan_interval: 60
1629+ rate_limit: 1000
16001630 "# ,
16011631 FactConfig {
16021632 paths : Some ( vec ! [ PathBuf :: from( "/etc" ) , PathBuf :: from( "/bin" ) ] ) ,
@@ -1627,7 +1657,7 @@ fn update() {
16271657 } ,
16281658 hotreload : Some ( true ) ,
16291659 scan_interval : Some ( Duration :: from_secs ( 30 ) ) ,
1630- rate_limit : None ,
1660+ rate_limit : Some ( 5000 ) ,
16311661 } ,
16321662 FactConfig {
16331663 paths : Some ( vec ! [ PathBuf :: from( "/etc" ) ] ) ,
@@ -1658,7 +1688,7 @@ fn update() {
16581688 } ,
16591689 hotreload : Some ( false ) ,
16601690 scan_interval : Some ( Duration :: from_secs ( 60 ) ) ,
1661- rate_limit : None ,
1691+ rate_limit : Some ( 1000 ) ,
16621692 } ,
16631693 ) ,
16641694 ] ;
@@ -1696,6 +1726,8 @@ fn defaults() {
16961726 assert_eq ! ( config. grpc. backoff. multiplier( ) , 1.5 ) ;
16971727 assert_eq ! ( config. grpc. backoff. retries( ) , 10 ) ;
16981728 assert_eq ! ( config. otel. endpoint( ) , None ) ;
1729+ assert_eq ! ( config. scan_interval( ) , Duration :: from_secs( 30 ) ) ;
1730+ assert_eq ! ( config. rate_limit( ) , 0 ) ;
16991731}
17001732
17011733static ENV_MUTEX : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
0 commit comments