diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2019-12-16 21:15:41 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-16 21:15:41 +0000 |
commit | ec498c5968974012d50d6d04c26cd2cd0db87d22 (patch) | |
tree | 39a80b70f400f27bd4af3d83748112bfed7cc3b4 /src/mongo/db/commands.h | |
parent | d9f793354be29ef51e7d32e8cb46e7bf84b99d66 (diff) | |
download | mongo-ec498c5968974012d50d6d04c26cd2cd0db87d22.tar.gz |
SERVER-44510 Implement exhaust isMaster
Diffstat (limited to 'src/mongo/db/commands.h')
-rw-r--r-- | src/mongo/db/commands.h | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 69ececd390c..efc4230556f 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -554,9 +554,10 @@ private: /** * A subclass of Command that only cares about the BSONObj body and doesn't need access to document - * sequences. + * sequences. Commands should implement this class if they require access to the + * ReplyBuilderInterface (e.g. to set the next invocation for an exhaust command). */ -class BasicCommand : public Command { +class BasicCommandWithReplyBuilderInterface : public Command { private: class Invocation; @@ -576,15 +577,12 @@ public: // /** - * run the given command - * implement this... - * - * return value is true if succeeded. if false, set errmsg text. + * Runs the given command. Returns true upon success. */ - virtual bool run(OperationContext* opCtx, - const std::string& db, - const BSONObj& cmdObj, - BSONObjBuilder& result) = 0; + virtual bool runWithReplyBuilder(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + rpc::ReplyBuilderInterface* replyBuilder) = 0; /** * Commands which can be explained override this method. Any operation which has a query @@ -690,6 +688,30 @@ private: }; /** + * Commands should implement this class if they do not require access to the ReplyBuilderInterface. + */ +class BasicCommand : public BasicCommandWithReplyBuilderInterface { +public: + using BasicCommandWithReplyBuilderInterface::BasicCommandWithReplyBuilderInterface; + + /** + * Runs the given command. Returns true upon success. + */ + virtual bool run(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + BSONObjBuilder& result) = 0; + + bool runWithReplyBuilder(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + rpc::ReplyBuilderInterface* replyBuilder) final { + auto result = replyBuilder->getBodyBuilder(); + return run(opCtx, db, cmdObj, result); + } +}; + +/** * Deprecated. Do not add new subclasses. */ class ErrmsgCommandDeprecated : public BasicCommand { |