std::string ConnectionOptions::getDisplayString()

in squangle/mysql_client/Operation.cpp [59:90]


std::string ConnectionOptions::getDisplayString() const {
  // Reserve 4 + 2 extra elements
  folly::small_vector<std::string, 6> parts;

  parts.push_back(
      folly::sformat("conn timeout={}us", connection_timeout_.count()));
  parts.push_back(folly::sformat("query timeout={}us", query_timeout_.count()));
  parts.push_back(folly::sformat("total timeout={}us", total_timeout_.count()));
  parts.push_back(folly::sformat("conn attempts={}", max_attempts_));
  if (dscp_.has_value()) {
    parts.push_back(folly::sformat("outbound dscp={}", *dscp_));
  }
  if (ssl_options_provider_ != nullptr) {
    parts.push_back(folly::sformat(
        "SSL options provider={}", (void*)ssl_options_provider_.get()));
  }
  if (compression_lib_.has_value()) {
    parts.push_back(folly::sformat(
        "compression library={}", (void*)compression_lib_.get_pointer()));
  }

  if (!attributes_.empty()) {
    std::vector<std::string> substrings;
    for (const auto& [key, value] : attributes_) {
      substrings.push_back(folly::sformat("{}={}", key, value));
    }

    parts.push_back(folly::sformat(
        "connection attributes=[{}]", folly::join(",", substrings)));
  }
  return folly::sformat("({})", folly::join(", ", parts));
}