(self)
| 140 | } |
| 141 | |
| 142 | async fn get_meta(self) -> Result<GetMetaResponse> { |
| 143 | let state = self.state.lock(); |
| 144 | let handshakes = state.latest_handshakes(None)?; |
| 145 | |
| 146 | // Total registered instances |
| 147 | let registered = state.state.instances.len(); |
| 148 | |
| 149 | // Get current timestamp |
| 150 | let now = SystemTime::now() |
| 151 | .duration_since(UNIX_EPOCH) |
| 152 | .context("system time before Unix epoch")? |
| 153 | .as_secs(); |
| 154 | |
| 155 | // Count online instances (those with handshakes in last 5 minutes) |
| 156 | let online = handshakes |
| 157 | .values() |
| 158 | .filter(|(ts, _)| { |
| 159 | // Skip instances that never connected (ts == 0) |
| 160 | *ts != 0 && now.saturating_sub(*ts) < 300 |
| 161 | }) |
| 162 | .count(); |
| 163 | |
| 164 | Ok(GetMetaResponse { |
| 165 | registered: registered as u32, |
| 166 | online: online as u32, |
| 167 | }) |
| 168 | } |
| 169 | |
| 170 | async fn set_node_url(self, request: SetNodeUrlRequest) -> Result<()> { |
| 171 | let kv_store = self.state.kv_store(); |
nothing calls this directly
no test coverage detected