diff options
author | Hugh Tong <hugh.tong@mongodb.com> | 2023-05-04 16:34:50 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-04 19:07:01 +0000 |
commit | f4765426f078a63ee59e065d37ae15e9234b3238 (patch) | |
tree | ee5933816d44403f260c5180ad0c649a3ff60db6 /src/mongo/util | |
parent | fba9dd05de659730512c9f2af0752cc71793c2fd (diff) | |
download | mongo-f4765426f078a63ee59e065d37ae15e9234b3238.tar.gz |
SERVER-76612 Copy SerializationContext between requests for views on agg
Diffstat (limited to 'src/mongo/util')
-rw-r--r-- | src/mongo/util/serialization_context.h | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/mongo/util/serialization_context.h b/src/mongo/util/serialization_context.h index d1844327ac7..356cc3e9c8c 100644 --- a/src/mongo/util/serialization_context.h +++ b/src/mongo/util/serialization_context.h @@ -31,6 +31,7 @@ #include <boost/optional.hpp> #include "mongo/util/static_immortal.h" +#include "mongo/util/str.h" namespace mongo { @@ -140,6 +141,24 @@ struct SerializationContext { return _nonPrefixedTenantId; } + std::string toString() const { + auto stream = str::stream(); + stream << "Source: " + << (_source == Source::Command + ? "Command" + : (_source == Source::Storage ? "Storage" : "Default")); + stream << ", CallerType: " + << (_callerType == CallerType::Request + ? "Request" + : (_callerType == CallerType::Reply ? "Reply" : "None")); + stream << ", PrefixState: " + << (_prefixState == Prefix::IncludePrefix + ? "Include" + : (_prefixState == Prefix::ExcludePrefix ? "Exclude" : "Missing")); + stream << ", non-prefixed tid: " << (_nonPrefixedTenantId ? "true" : "false"); + return stream; + } + friend bool operator==(const SerializationContext& lhs, const SerializationContext& rhs) { return (lhs._prefixState == rhs._prefixState) && (lhs._callerType == rhs._callerType) && (lhs._source == rhs._source); @@ -155,13 +174,18 @@ private: Prefix _prefixState; /** - * This flag is set/produced at command parsing before the deserializer is called, and consumed - * by the serializer. It indicates whether the tenantId was sourced from the $tenant field or - * security token (ie. true), or if it was sourced from parsing the db string prefix (ie. - * false). This is important as the serializer uses this flag to determine whether the reponse - * should contain a prefixed tenantId when serializing for commands. + * This flag is set/produced at command parsing before the deserializer is called, and + * consumed by the serializer. It indicates whether the tenantId was sourced from the + * $tenant field or security token (ie. true), or if it was sourced from parsing the db + * string prefix (ie. false). This is important as the serializer uses this flag to + * determine whether the reponse should contain a prefixed tenantId when serializing for + * commands. */ bool _nonPrefixedTenantId; }; +inline std::ostream& operator<<(std::ostream& os, const SerializationContext& sc) { + return os << sc.toString(); +} + } // namespace mongo |