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

+68
View File
@@ -67,6 +67,7 @@ constexpr auto kDescribeEvalTimeout = std::chrono::seconds{10};
constexpr std::size_t kMaxDescribeProfileBytes = 128U;
constexpr std::size_t kMaxDescribeTargetNames = 128U;
constexpr std::size_t kMaxDescribeTargetNameBytes = 200U;
constexpr std::size_t kMaxDoctorToolPathBytes = 4096U;
constexpr std::size_t kMaxBuildTargets = 64U;
constexpr std::size_t kMaxCompdbArguments = 256U;
constexpr std::size_t kMaxCompdbArgumentBytes = 1024U;
@@ -2090,6 +2091,73 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
object.emplace("socket", JsonValue{socket_path.string()});
return {serialize_response(JsonValue{std::move(object)}), false};
}
if (*name == "doctor") {
struct ToolProbe {
std::string_view name;
const char *binary;
bool required;
};
constexpr ToolProbe kToolProbes[]{
{"g++", "g++", true},
{"clang++", "clang++", false},
{"clang-scan-deps", "clang-scan-deps", false},
{"ar", "ar", true},
{"git", "git", false},
{"cmake", "cmake", false},
{"ninja", "ninja", false},
{"meson", "meson", false},
{"conan", "conan", false},
{"clang-format", "clang-format", false},
};
JsonValue::Array tools;
JsonValue::Array missing_required;
for (const auto &probe : kToolProbes) {
const auto found = Platform::resolve_executable(probe.binary);
JsonValue::Object tool;
tool.emplace("name", JsonValue{std::string{probe.name}});
tool.emplace("required", JsonValue{probe.required});
tool.emplace("found", JsonValue{found.has_value()});
std::string path = found ? found->string() : std::string{};
if (path.size() > kMaxDoctorToolPathBytes) {
path.resize(kMaxDoctorToolPathBytes);
}
tool.emplace("path", JsonValue{std::move(path)});
if (probe.required && !found) {
missing_required.emplace_back(std::string{probe.name});
}
tools.emplace_back(std::move(tool));
}
#if defined(VBS_HAS_VOID_SQLITE)
constexpr bool has_sqlite = true;
#else
constexpr bool has_sqlite = false;
#endif
#if defined(VBS_HAS_VOID_NET)
constexpr bool has_net = true;
#else
constexpr bool has_net = false;
#endif
JsonValue::Object backends;
backends.emplace("file_ops", JsonValue{Platform::host_supported()});
backends.emplace("process_supervisor", JsonValue{Platform::host_supported()});
backends.emplace("directory_watcher", JsonValue{Platform::host_supported()});
backends.emplace("sqlite", JsonValue{has_sqlite});
backends.emplace("net", JsonValue{has_net});
JsonValue::Object response;
response.emplace("ok", JsonValue{true});
response.emplace("op", JsonValue{std::string{"doctor"}});
response.emplace("version", JsonValue{std::string{Bootstrap::version}});
response.emplace("os", JsonValue{std::string{Bootstrap::os}});
response.emplace("architecture", JsonValue{std::string{Bootstrap::architecture}});
response.emplace("host_os",
JsonValue{std::string{Platform::host_os_name(Platform::host_os())}});
response.emplace("host_supported", JsonValue{Platform::host_supported()});
response.emplace("tools", JsonValue{std::move(tools)});
response.emplace("healthy", JsonValue{missing_required.empty()});
response.emplace("missing_required", JsonValue{std::move(missing_required)});
response.emplace("backends", JsonValue{std::move(backends)});
return {serialize_response(JsonValue{std::move(response)}), false};
}
if (*name == "editor_status") {
return {editor_status_project(options), false};
}