Skip to content

Commit

Permalink
[OMON-781] Provide active env run lists from Kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
awegrzyn committed Jul 10, 2024
1 parent b4a20a5 commit a7637a3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/8-KafkaToHttpServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ void httpServer(tcp::acceptor& acceptor, tcp::socket& socket) {
}
beast::ostream(response.body()) << jsonPrefix << envsJson << jsonSuffix << '\n';
});
connection->addCallback("SHOW+TAG+VALUES+FROM+envs",
[](http::request<http::dynamic_body>& /*request*/, http::response<http::dynamic_body>& response) {
std::string jsonPrefix = R"({"results": [{"statement_id": 0, "series": [{"name": "env_active", "columns": ["key", "value"], "values": [)";
std::string jsonSuffix = R"(]}]}]})";
response.set(http::field::content_type, "application/json");
const std::lock_guard<std::mutex> lock(gEnvAccess);
std::string envsJson;
for (int i = 0; i < gActiveEnvs.activeruns_size(); i++) {
envsJson += "[\"env\", \"" + std::to_string(gActiveEnvs.activeruns(i).environmentid()) + "\"],";
}
if (!envsJson.empty()) {
envsJson.pop_back();
} else {
envsJson += "[\"env\", \"0\"]";
}
beast::ostream(response.body()) << jsonPrefix << envsJson << jsonSuffix << '\n';
});
connection->addCallback("SHOW+TAG+VALUES+FROM+detectors",
[](http::request<http::dynamic_body>& request, http::response<http::dynamic_body>& response) {
std::string jsonPrefix = R"({"results": [{"statement_id": 0, "series": [{"name": "detectors", "columns": ["key", "value"], "values": [)";
Expand Down

0 comments on commit a7637a3

Please sign in to comment.