feat(registry,daemon): report registry stats; serve daemon doctor
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-04 06:48:09 +03:00
1 parent e61eff7a8f
commit 1aaece3231
8 files changed
+230 -4

No files matched your search

+24 -1
View File
@@ -1775,7 +1775,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
// Admin endpoints: users, audit, storage.
if (req.path == "/api/v1/users" || req.path == "/api/v1/audit" ||
req.path == "/api/v1/admin/storage") {
req.path == "/api/v1/stats" || req.path == "/api/v1/admin/storage") {
if (!principal) {
return HttpResponse::error_json(401, "unauthorized", "authentication required");
}
@@ -1887,6 +1887,29 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
",\"quota_bytes\":" + std::to_string(config_.max_storage_bytes) +
",\"package_count\":" + std::to_string(packages_.size()) + "}\n");
}
if (req.path == "/api/v1/stats" && req.method == "GET") {
std::size_t release_count = 0;
std::size_t binary_count = 0;
std::size_t yanked_releases = 0;
for (const auto &[name, package] : packages_) {
release_count += package.releases.size();
for (const auto &[version, release] : package.releases) {
binary_count += release.binaries.size();
if (release.yanked) {
++yanked_releases;
}
}
}
return with_etag(
HttpResponse::json(
200, "{\"packages\":" + std::to_string(packages_.size()) +
",\"releases\":" + std::to_string(release_count) +
",\"yanked_releases\":" + std::to_string(yanked_releases) +
",\"binary_variants\":" + std::to_string(binary_count) +
",\"users\":" + std::to_string(users_.size()) +
",\"audit_entries\":" + std::to_string(audits_.size()) + "}\n"),
req);
}
}
return HttpResponse::error_json(404, "not_found", "unknown API endpoint");