summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands.h
diff options
context:
space:
mode:
authorFernando Lisboa <fernando.lisboa@mongodb.com>2022-07-07 06:01:10 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-07 06:50:27 +0000
commite756e14a6679b3a97b5f7438f984d5b40736d1e8 (patch)
treebe1365658fa24cb58abf6f73fcee7573ec24b0af /src/mongo/db/commands.h
parent10df28a8ef8b90ebdf75b20cfd4731d89feda46b (diff)
downloadmongo-e756e14a6679b3a97b5f7438f984d5b40736d1e8.tar.gz
SERVER-66561: Change BasicCommandWithReplyBuilderInterface to use DatabaseName
Diffstat (limited to 'src/mongo/db/commands.h')
-rw-r--r--src/mongo/db/commands.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index 15f80320e0f..bc1d274a4f8 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -856,7 +856,7 @@ public:
* Runs the given command. Returns true upon success.
*/
virtual bool runWithReplyBuilder(OperationContext* opCtx,
- const std::string& db,
+ const DatabaseName& dbName,
const BSONObj& cmdObj,
rpc::ReplyBuilderInterface* replyBuilder) = 0;
@@ -864,9 +864,10 @@ public:
* Provides a future that may run the command asynchronously. By default, it falls back to
* runWithReplyBuilder.
*/
- virtual Future<void> runAsync(std::shared_ptr<RequestExecutionContext> rec, std::string db) {
+ virtual Future<void> runAsync(std::shared_ptr<RequestExecutionContext> rec,
+ const DatabaseName& dbName) {
if (!runWithReplyBuilder(
- rec->getOpCtx(), db, rec->getRequest().body, rec->getReplyBuilder()))
+ rec->getOpCtx(), dbName, rec->getRequest().body, rec->getReplyBuilder()))
return Status(ErrorCodes::FailedToRunWithReplyBuilder,
fmt::format("Failed to run command: {}", rec->getCommand()->getName()));
return Status::OK();
@@ -1002,11 +1003,12 @@ public:
BSONObjBuilder& result) = 0;
bool runWithReplyBuilder(OperationContext* opCtx,
- const std::string& db,
+ const DatabaseName& dbName,
const BSONObj& cmdObj,
rpc::ReplyBuilderInterface* replyBuilder) override {
auto result = replyBuilder->getBodyBuilder();
- return run(opCtx, db, cmdObj, result);
+ // TODO SERVER-67459 change BasicCommand::run to take in DatabaseName
+ return run(opCtx, dbName.toStringWithTenantId(), cmdObj, result);
}
};
@@ -1066,7 +1068,7 @@ protected:
BasicCommandWithRequestParser(StringData name) : BasicCommandWithReplyBuilderInterface(name) {}
bool runWithReplyBuilder(OperationContext* opCtx,
- const std::string& db,
+ const DatabaseName& dbName,
const BSONObj& cmdObj,
rpc::ReplyBuilderInterface* replyBuilder) final {
auto result = replyBuilder->getBodyBuilder();
@@ -1074,7 +1076,8 @@ protected:
// To enforce API versioning
auto requestParser = RequestParser(opCtx, cmdObj);
- auto cmdDone = runWithRequestParser(opCtx, db, cmdObj, requestParser, result);
+ auto cmdDone = runWithRequestParser(
+ opCtx, dbName.toStringWithTenantId(), cmdObj, requestParser, result);
// Only validate results in test mode so that we don't expose users to errors if we
// construct an invalid reply.