9#include "MonitoringService.grpc.pb.h"
10#include "MonitoringService.pb.h"
13#include "clang/Basic/Version.h"
14#include "llvm/Support/CommandLine.h"
15#include "llvm/Support/Signals.h"
18#include <google/protobuf/util/json_util.h>
19#include <grpc++/grpc++.h>
26static constexpr char Overview[] = R
"(
27This tool requests monitoring information (uptime, index freshness) from the
28server and prints it to stdout.
31llvm::cl::opt<std::string>
32 ServerAddress("server-address", llvm::cl::Positional,
33 llvm::cl::desc(
"Address of the invoked server."),
41int main(
int argc,
char *argv[]) {
43 llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
44 llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
47 grpc::CreateChannel(ServerAddress, grpc::InsecureChannelCredentials());
48 const auto Stub = clang::clangd::remote::v1::Monitor::NewStub(Channel);
50 Context.set_deadline(std::chrono::system_clock::now() +
51 std::chrono::seconds(10));
52 Context.AddMetadata(
"version", clang::getClangToolFullVersion(
"clangd"));
53 const clang::clangd::remote::v1::MonitoringInfoRequest Request;
54 clang::clangd::remote::v1::MonitoringInfoReply Response;
55 const auto Status = Stub->MonitoringInfo(&
Context, Request, &Response);
58 Status.error_code(), Status.error_message());
62 google::protobuf::util::JsonPrintOptions Options;
63 Options.add_whitespace =
true;
64 Options.always_print_primitive_fields =
true;
65 Options.preserve_proto_field_names =
true;
66 const auto JsonStatus =
67 google::protobuf::util::MessageToJsonString(Response, &
Output, Options);
68 if (!JsonStatus.ok()) {
70 Response.DebugString(),
71 static_cast<int>(JsonStatus.code()),
72 JsonStatus.message().as_string());
int main(int argc, char *argv[])
A context is an immutable container for per-request data that must be propagated through layers that ...
void elog(const char *Fmt, Ts &&... Vals)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//