From fcb69334e15e32049a45ebdcc7d2988acf441f5e Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Tue, 9 Feb 2021 15:06:07 -0500 Subject: SERVER-52542 Convert dropIndexes to IDL --- src/mongo/db/commands.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/mongo/db/commands.h') diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 2d3df2eb106..813c5397ab2 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -930,6 +930,23 @@ public: } }; +namespace { +// Used in BasicCommandWithRequestParser below. +template +struct CommandAlias { + // An empty alias is equivalent to no alias, see CommandRegistry::registerCommand. + static constexpr StringData kAlias = ""_sd; +}; + +template +struct CommandAlias { + static constexpr StringData kAlias = T::kCommandAlias; +}; + +template +constexpr StringData command_alias_v = CommandAlias::kAlias; +} // namespace + /** * A CRTP base class for BasicCommandWithRequestParser, which simplifies writing commands that * accept requests generated by IDL to enforce API versioning and to overcome the complexity @@ -952,7 +969,8 @@ public: * * which enables it to be parsed as an IDL command. * - * - a 'constexpr StringData kCommandName' member. + * - a 'static constexpr StringData kCommandName' member. + * - (optional) a 'static constexpr StringData kCommandAlias' member. * * - validateResult: that has a custom logic to validate the result BSON object * to enforce API versioning. @@ -961,9 +979,9 @@ public: template class BasicCommandWithRequestParser : public BasicCommandWithReplyBuilderInterface { protected: - // Commands that only have a single name don't need to define any constructors. BasicCommandWithRequestParser() - : BasicCommandWithReplyBuilderInterface(Derived::Request::kCommandName) {} + : BasicCommandWithReplyBuilderInterface(Derived::Request::kCommandName, + command_alias_v) {} bool runWithReplyBuilder(OperationContext* opCtx, const std::string& db, @@ -1003,7 +1021,7 @@ protected: auto wcStatus = getWriteConcernStatusFromCommandResult(resultObj); if (!wcStatus.isOK()) { if (wcStatus.code() == ErrorCodes::TypeMismatch) { - // Result has "writeConcerError" field but it is not valid wce object. + // Result has "writeConcernError" field but it is not valid wce object. uassertStatusOK(wcStatus); } } -- cgit v1.2.1