Add refresh shortkey 'r' for on-demand metrics refresh
Implements ZMQ command protocol for dashboard-to-agent communication: - Agents listen on port 6131 for REQ/REP commands - Dashboard sends "refresh" command when 'r' key is pressed - Agents force immediate collection of all metrics via force_refresh_all() - Fresh data is broadcast immediately to dashboard - Updated help text to show "r: Refresh all metrics" Also includes metric-level caching architecture foundation for future granular control over individual metric update frequencies.
This commit is contained in:
@@ -69,6 +69,7 @@ pub struct App {
|
||||
active_host_index: usize,
|
||||
show_help: bool,
|
||||
should_quit: bool,
|
||||
refresh_requested: bool,
|
||||
last_tick: Instant,
|
||||
tick_count: u64,
|
||||
status: String,
|
||||
@@ -106,6 +107,7 @@ impl App {
|
||||
active_host_index: 0,
|
||||
show_help: false,
|
||||
should_quit: false,
|
||||
refresh_requested: false,
|
||||
last_tick: Instant::now(),
|
||||
tick_count: 0,
|
||||
status,
|
||||
@@ -138,7 +140,8 @@ impl App {
|
||||
self.status = "Exiting…".to_string();
|
||||
}
|
||||
KeyCode::Char('r') | KeyCode::Char('R') => {
|
||||
self.status = "Manual refresh requested".to_string();
|
||||
self.refresh_requested = true;
|
||||
self.status = "Refresh requested - sending commands to agents...".to_string();
|
||||
}
|
||||
KeyCode::Left | KeyCode::Char('h') => {
|
||||
self.select_previous_host();
|
||||
@@ -156,6 +159,15 @@ impl App {
|
||||
pub fn should_quit(&self) -> bool {
|
||||
self.should_quit
|
||||
}
|
||||
|
||||
pub fn check_refresh_request(&mut self) -> bool {
|
||||
if self.refresh_requested {
|
||||
self.refresh_requested = false;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn status_text(&self) -> &str {
|
||||
@@ -256,6 +268,10 @@ impl App {
|
||||
self.zmq_subscription.clone(),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn zmq_endpoints(&self) -> &[String] {
|
||||
&self.zmq_endpoints
|
||||
}
|
||||
|
||||
pub fn handle_app_event(&mut self, event: AppEvent) {
|
||||
match event {
|
||||
@@ -337,6 +353,10 @@ impl App {
|
||||
|
||||
self.status = format!("Fetch failed • host: {} • {}", host, error);
|
||||
}
|
||||
AppEvent::RefreshRequested => {
|
||||
// Handle refresh command - will be implemented in the main loop
|
||||
self.status = "Refresh command sent to all agents".to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,5 +661,6 @@ pub enum AppEvent {
|
||||
error: String,
|
||||
timestamp: DateTime<Utc>,
|
||||
},
|
||||
RefreshRequested,
|
||||
Shutdown,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user