@@ -359,8 +359,8 @@ impl AdminApp {
359359 fn cache_activity_reset_response ( & self ) -> AdminResponse {
360360 let result = self . proxy . reset_cache_activity ( ) ;
361361 let body = format ! (
362- r#"{{"status":"ok","memory_tiers":{},"disk_tiers":{},"tiered_vhosts":{}}}"# ,
363- result. memory_tiers, result. disk_tiers, result. tiered_vhosts
362+ r#"{{"status":"ok","memory_tiers":{},"disk_tiers":{},"tiered_vhosts":{},"tiered_routes":{} }}"# ,
363+ result. memory_tiers, result. disk_tiers, result. tiered_vhosts, result . tiered_routes
364364 ) ;
365365 json_response ( StatusCode :: OK , body. as_bytes ( ) )
366366 }
@@ -1304,10 +1304,12 @@ fn cache_purge_results_json(results: &[crate::proxy::CachePurgeResult]) -> Strin
13041304#[ cfg( feature = "cache" ) ]
13051305fn cache_totals_json ( totals : & crate :: proxy:: CacheRuntimeTotals ) -> String {
13061306 format ! (
1307- r#"{{"vhosts":{},"enabled_vhosts":{},"tiered_vhosts":{},"memory_entries":{},"memory_weighted_size_bytes":{},"memory_max_size_bytes":{},"disk_entries":{},"disk_size_bytes":{},"disk_max_size_bytes":{},"activity":{}}}"# ,
1307+ r#"{{"vhosts":{},"enabled_vhosts":{},"tiered_vhosts":{},"enabled_routes":{},"tiered_routes":{}," memory_entries":{},"memory_weighted_size_bytes":{},"memory_max_size_bytes":{},"disk_entries":{},"disk_size_bytes":{},"disk_max_size_bytes":{},"activity":{}}}"# ,
13081308 totals. vhosts,
13091309 totals. enabled_vhosts,
13101310 totals. tiered_vhosts,
1311+ totals. enabled_routes,
1312+ totals. tiered_routes,
13111313 totals. memory_entries,
13121314 totals. memory_weighted_size_bytes,
13131315 totals. memory_max_size_bytes,
@@ -1332,12 +1334,32 @@ fn cache_vhost_stats_json(vhosts: &[crate::proxy::CacheVhostStats]) -> String {
13321334 body. push ( ',' ) ;
13331335 }
13341336 body. push_str ( & format ! (
1335- r#"{{"name":"{}","enabled":{},"tiered":{},"memory":{},"disk":{}}}"# ,
1337+ r#"{{"name":"{}","enabled":{},"tiered":{},"memory":{},"disk":{},"routes":[{}] }}"# ,
13361338 json_escape( & vhost. name) ,
13371339 vhost. enabled,
13381340 vhost. tiered,
13391341 memory_cache_stats_json( vhost. memory. as_ref( ) ) ,
1340- disk_cache_stats_json( vhost. disk. as_ref( ) )
1342+ disk_cache_stats_json( vhost. disk. as_ref( ) ) ,
1343+ cache_route_stats_json( & vhost. routes)
1344+ ) ) ;
1345+ }
1346+ body
1347+ }
1348+
1349+ #[ cfg( feature = "cache" ) ]
1350+ fn cache_route_stats_json ( routes : & [ crate :: proxy:: CacheRouteStats ] ) -> String {
1351+ let mut body = String :: new ( ) ;
1352+ for ( index, route) in routes. iter ( ) . enumerate ( ) {
1353+ if index > 0 {
1354+ body. push ( ',' ) ;
1355+ }
1356+ body. push_str ( & format ! (
1357+ r#"{{"name":"{}","enabled":{},"tiered":{},"memory":{},"disk":{}}}"# ,
1358+ json_escape( & route. name) ,
1359+ route. enabled,
1360+ route. tiered,
1361+ memory_cache_stats_json( route. memory. as_ref( ) ) ,
1362+ disk_cache_stats_json( route. disk. as_ref( ) )
13411363 ) ) ;
13421364 }
13431365 body
@@ -1580,7 +1602,7 @@ mod tests {
15801602 WebConfig ,
15811603 } ;
15821604 #[ cfg( feature = "cache" ) ]
1583- use crate :: config:: { ByteSize , CacheConfig } ;
1605+ use crate :: config:: { ByteSize , CacheConfig , RouteConfig } ;
15841606 use crate :: proxy:: { FluxProxy , ProxyHealthReporter , ProxyHealthSignal } ;
15851607 use crate :: snapshot:: SnapshotStore ;
15861608 use crate :: test_support:: unique_temp_path;
@@ -1817,7 +1839,7 @@ mod tests {
18171839 } ,
18181840 headers: crate :: config:: VhostHeaderPolicyConfig :: default ( ) ,
18191841 web: WebConfig :: default ( ) ,
1820- routes: Vec :: new ( ) ,
1842+ routes: vec! [ cached_assets_route ( ) ] ,
18211843 } ] ,
18221844 ..Config :: default ( )
18231845 } ;
@@ -1834,6 +1856,8 @@ mod tests {
18341856 assert ! ( body. contains( r#""totals":{"vhosts":1"# ) ) ;
18351857 assert ! ( body. contains( r#""enabled_vhosts":1"# ) ) ;
18361858 assert ! ( body. contains( r#""tiered_vhosts":1"# ) ) ;
1859+ assert ! ( body. contains( r#""enabled_routes":1"# ) ) ;
1860+ assert ! ( body. contains( r#""tiered_routes":0"# ) ) ;
18371861 assert ! ( body. contains( r#""memory_entries":0"# ) ) ;
18381862 assert ! ( body. contains( r#""disk_entries":0"# ) ) ;
18391863 assert ! ( body. contains( r#""activity":{"hits":0,"misses":0,"stores":0"# ) ) ;
@@ -1842,6 +1866,7 @@ mod tests {
18421866 assert ! ( body. contains( r#""tiered":true"# ) ) ;
18431867 assert ! ( body. contains( r#""memory":{"entries":0"# ) ) ;
18441868 assert ! ( body. contains( r#""disk":{"entries":0"# ) ) ;
1869+ assert ! ( body. contains( r#""routes":[{"name":"assets""# ) ) ;
18451870
18461871 std:: fs:: remove_dir_all ( cache_path) . unwrap ( ) ;
18471872 }
@@ -1875,7 +1900,7 @@ mod tests {
18751900 } ,
18761901 headers: crate :: config:: VhostHeaderPolicyConfig :: default ( ) ,
18771902 web: WebConfig :: default ( ) ,
1878- routes: Vec :: new ( ) ,
1903+ routes: vec! [ cached_assets_route ( ) ] ,
18791904 } ] ,
18801905 ..Config :: default ( )
18811906 } ;
@@ -1899,9 +1924,10 @@ mod tests {
18991924 assert_eq ! ( response. status, StatusCode :: OK ) ;
19001925 let body = String :: from_utf8 ( response. body ) . unwrap ( ) ;
19011926 assert ! ( body. contains( r#""status":"ok""# ) ) ;
1902- assert ! ( body. contains( r#""memory_tiers":1 "# ) ) ;
1927+ assert ! ( body. contains( r#""memory_tiers":2 "# ) ) ;
19031928 assert ! ( body. contains( r#""disk_tiers":1"# ) ) ;
19041929 assert ! ( body. contains( r#""tiered_vhosts":1"# ) ) ;
1930+ assert ! ( body. contains( r#""tiered_routes":0"# ) ) ;
19051931
19061932 std:: fs:: remove_dir_all ( cache_path) . unwrap ( ) ;
19071933 }
@@ -2850,6 +2876,32 @@ mod tests {
28502876 headers
28512877 }
28522878
2879+ #[ cfg( feature = "cache" ) ]
2880+ fn cached_assets_route ( ) -> RouteConfig {
2881+ RouteConfig {
2882+ name : "assets" . to_owned ( ) ,
2883+ path_exact : None ,
2884+ path_prefix : Some ( "/assets/" . to_owned ( ) ) ,
2885+ fallback : false ,
2886+ https_redirect_exempt : false ,
2887+ strip_prefix : None ,
2888+ max_request_body_bytes : None ,
2889+ redirect : None ,
2890+ proxy : Some ( ProxyConfig :: default ( ) ) ,
2891+ web : None ,
2892+ cache : Some ( CacheConfig {
2893+ enabled : true ,
2894+ memory : crate :: config:: CacheMemoryConfig {
2895+ enabled : true ,
2896+ max_size_bytes : ByteSize :: from_bytes ( 1024 ) ,
2897+ } ,
2898+ max_object_bytes : ByteSize :: from_bytes ( 512 ) ,
2899+ ..CacheConfig :: default ( )
2900+ } ) ,
2901+ headers : crate :: config:: VhostHeaderPolicyConfig :: default ( ) ,
2902+ }
2903+ }
2904+
28532905 struct TestDir {
28542906 path : std:: path:: PathBuf ,
28552907 }
0 commit comments