Skip to content

Commit

Permalink
Update Mcpiper to print Thrift Structures using JSONSerializer
Browse files Browse the repository at this point in the history
Summary: Use JSONSerializer to print thrift objects.

Reviewed By: stuclar

Differential Revision: D17744765

fbshipit-source-id: 6ed74e173642e412a16bd8be1eda511fd13d48c8
  • Loading branch information
Soham Shah authored and facebook-github-bot committed Nov 7, 2019
1 parent 5b8c332 commit 16416eb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mcrouter/tools/mcpiper/McPiperVisitor.h
Expand Up @@ -16,6 +16,8 @@
#include <folly/Optional.h>
#include <folly/Range.h>
#include <thrift/lib/cpp2/FieldRef.h>
#include <thrift/lib/cpp2/protocol/Serializer.h>
#include <thrift/lib/cpp2/protocol/SimpleJSONProtocol.h>

#include "mcrouter/lib/carbon/CommonSerializationTraits.h"
#include "mcrouter/lib/carbon/Fields.h"
Expand Down Expand Up @@ -237,9 +239,11 @@ class McPiperVisitor {
std::enable_if_t<
carbon::IsThriftWrapperStruct<T>::value,
facebook::memcache::StyledString>
serialize(const T& /* value */) {
serialize(const T& t) {
facebook::memcache::StyledString out;
out.append(serializeString("<Thrift structure>"));
out.append(serializeString(
apache::thrift::SimpleJSONSerializer::serialize<std::string>(
t.getThriftStruct())));
return out;
}

Expand Down Expand Up @@ -316,7 +320,7 @@ class McPiperVisitor {
}
};

} // detail
} // namespace detail

template <class R>
facebook::memcache::StyledString
Expand All @@ -326,4 +330,4 @@ print(const R& req, folly::StringPiece /* name */, bool script) {
return std::move(printer).styled();
}

} // carbon
} // namespace carbon

0 comments on commit 16416eb

Please sign in to comment.