brbzull0 commented on code in PR #12245: URL: https://github.com/apache/trafficserver/pull/12245#discussion_r2097394795
########## src/iocore/net/ConnectionTracker.cc: ########## @@ -318,13 +318,61 @@ ConnectionTracker::get_outbound_groups(std::vector<std::shared_ptr<Group const>> } } +void +ConnectionTracker::get_inbound_groups(std::vector<std::shared_ptr<Group const>> &groups) +{ + std::lock_guard<std::mutex> lock(_inbound_table._mutex); // TABLE LOCK + groups.resize(0); + groups.reserve(_inbound_table._table.size()); + for (auto &&[key, group] : _inbound_table._table) { + groups.push_back(group); + } +} std::string -ConnectionTracker::outbound_to_json_string() +ConnectionTracker::inbound_to_json_string() { std::string text; size_t extent = 0; - static const swoc::bwf::Format header_fmt{R"({{"count": {}, "list": [ + static const swoc::bwf::Format header_fmt{R"({{"count": {}, "list": [ )"}; + static const swoc::bwf::Format item_fmt{ + R"( {{"type": "{}", "ip": "{}", "fqdn": "{}", "current": {}, "max": {}, "blocked": {}, "alert": {}}}, )"}; + static const std::string_view trailer{" \n]}"}; + + static const auto printer = [](swoc::BufferWriter &w, Group const *g) -> swoc::BufferWriter & { + w.print(item_fmt, g->_match_type, g->_addr, g->_fqdn, g->_count.load(), g->_count_max.load(), g->_blocked.load(), + g->get_last_alert_epoch_time()); + return w; + }; + + swoc::FixedBufferWriter null_bw{nullptr}; // Empty buffer for sizing work. + std::vector<std::shared_ptr<Group const>> groups; + + self_type::get_inbound_groups(groups); Review Comment: yup, agreed. Done! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org