std::string AccessPoint::toString() const {
  assert(protocol_ != mc_unknown_protocol);
  if (isV6_) {
    return folly::to<std::string>(
        "[",
        host_,
        "]:",
        port_,
        ":",
        mc_protocol_to_string(protocol_),
        ":",
        securityMechToString(securityMech_),
        ":",
        compressed_ ? "compressed" : "notcompressed");
  }
  return folly::to<std::string>(
      host_,
      ":",
      port_,
      ":",
      mc_protocol_to_string(protocol_),
      ":",
      securityMechToString(securityMech_),
      ":",
      compressed_ ? "compressed" : "notcompressed");
}
std::string MessagePrinter::serializeConnectionDetails(
    const folly::SocketAddress& from,
    const folly::SocketAddress& to,
    mc_protocol_t protocol) {
  std::string out;

  if (!from.empty()) {
    if (options_.script) {
      out.append(
          folly::sformat(",\n  \"from\": \"{}\"", describeAddress(from)));
    } else {
      out.append(describeAddress(from));
    }
  }
  if (!options_.script && (!from.empty() || !to.empty())) {
    out.append(" -> ");
  }
  if (!to.empty()) {
    if (options_.script) {
      out.append(folly::sformat(",\n  \"to\": \"{}\"", describeAddress(to)));
    } else {
      out.append(describeAddress(to));
    }
  }
  if ((!from.empty() || !to.empty()) && protocol != mc_unknown_protocol) {
    if (options_.script) {
      out.append(folly::sformat(
          ",\n  \"protocol\": \"{}\"", mc_protocol_to_string(protocol)));
    } else {
      out.append(folly::sformat(" ({})", mc_protocol_to_string(protocol)));
    }
  }

  return out;
}
Exemple #3
0
std::string AccessPoint::toString() const {
    assert(protocol_ != mc_unknown_protocol);
    if (isV6_) {
        return folly::to<std::string>("[", host_, "]:", port_, ":",
                                      mc_protocol_to_string(protocol_),
                                      ":", useSsl_ ? "ssl" : "plain");
    }
    return folly::to<std::string>(host_, ":", port_, ":",
                                  mc_protocol_to_string(protocol_),
                                  ":", useSsl_ ? "ssl" : "plain");
}
std::string MessagePrinter::serializeConnectionDetails(
    const folly::SocketAddress& from,
    const folly::SocketAddress& to,
    mc_protocol_t protocol) {
  std::string out;

  if (!from.empty()) {
    out.append(from.describe());
  }
  if (!from.empty() || !to.empty()) {
    out.append(" -> ");
  }
  if (!to.empty()) {
    out.append(to.describe());
  }
  if ((!from.empty() || !to.empty()) && protocol != mc_unknown_protocol) {
    out.append(folly::sformat(" ({})", mc_protocol_to_string(protocol)));
  }

  return out;
}