(
top: Option<usize>,
)
| 3923 | } |
| 3924 | |
| 3925 | pub async fn fetch_admin_memory_profiler_modules( |
| 3926 | top: Option<usize>, |
| 3927 | ) -> Result<MemoryModuleReport, String> { |
| 3928 | #[cfg(feature = "mock")] |
| 3929 | { |
| 3930 | Ok(MemoryModuleReport { |
| 3931 | generated_at_ms: Date::now() as i64, |
| 3932 | top: top.unwrap_or(20), |
| 3933 | total_live_bytes_estimate: 0, |
| 3934 | process_rss_bytes: 0, |
| 3935 | entries: vec![], |
| 3936 | }) |
| 3937 | } |
| 3938 | |
| 3939 | #[cfg(not(feature = "mock"))] |
| 3940 | { |
| 3941 | let mut url = format!("{}/admin/runtime/memory/modules", admin_base()); |
| 3942 | if let Some(top) = top { |
| 3943 | url.push_str(&format!("?top={top}")); |
| 3944 | } |
| 3945 | let response = api_get(&url) |
| 3946 | .send() |
| 3947 | .await |
| 3948 | .map_err(|e| format!("Network error: {:?}", e))?; |
| 3949 | if !response.ok() { |
| 3950 | return Err(format!("HTTP error: {}", response.status())); |
| 3951 | } |
| 3952 | response |
| 3953 | .json() |
| 3954 | .await |
| 3955 | .map_err(|e| format!("Parse error: {:?}", e)) |
| 3956 | } |
| 3957 | } |
| 3958 | |
| 3959 | pub async fn admin_reset_memory_profiler() -> Result<(), String> { |
| 3960 | #[cfg(feature = "mock")] |
no test coverage detected