[Server] Expose the latest uptime snapshot on the database interface (#7840)

cmdGetServerStats reached through Servatrice_DatabaseInterface for checkSql and
getLatestUptimeSnapshot, a concrete-only method. Move the UptimeSnapshot record
to Server_DatabaseInterface with an invalid default for non-SQL stores, mark the
Servatrice implementation as an override, and let the command ask the injected
interface. The statement, its bind value and the invalid-snapshot response are
unchanged.
This commit is contained in:
BruebachL 2026-11-10 12:16:25 +01:00 • committed by GitHub
parent 03adbd9787
commit 7719ff021c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 15 deletions

View file

@ -2186,13 +2186,13 @@ Response::ResponseCode AbstractServerSocketInterface::cmdReportUserInfo(const Co
Response::ResponseCode AbstractServerSocketInterface::cmdGetServerStats(const Command_GetServerStats & /*cmd */,
ResponseContainer &rc)
{
if (!sqlInterface->checkSql()) {
if (!databaseInterface->checkSql()) {
return Response::RespInternalError;
}
// Servatrice::statusUpdate() periodically snapshots server health into the
// uptime table. Serve the freshest snapshot for this server.
const auto snapshot = sqlInterface->getLatestUptimeSnapshot(servatrice->getServerID());
const auto snapshot = databaseInterface->getLatestUptimeSnapshot(servatrice->getServerID());
if (!snapshot.valid) {
// No snapshot yet (fresh server, or statusUpdate() has not ticked).
return Response::RespInternalError;