summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/dbcommands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/dbcommands.cpp')
-rw-r--r--src/mongo/db/commands/dbcommands.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 06634e1e68b..822443eb434 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -83,13 +83,16 @@
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_coordinator.h"
+#include "mongo/db/request_execution_context.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/stats/storage_stats.h"
#include "mongo/db/storage/storage_engine_init.h"
#include "mongo/db/write_concern.h"
+#include "mongo/executor/async_request_executor.h"
#include "mongo/logv2/log.h"
#include "mongo/scripting/engine.h"
#include "mongo/util/fail_point.h"
+#include "mongo/util/future.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/scopeguard.h"
#include "mongo/util/version.h"
@@ -781,6 +784,26 @@ public:
} cmdDBStats;
+// Provides the means to asynchronously run `buildinfo` commands.
+class BuildInfoExecutor final : public AsyncRequestExecutor {
+public:
+ BuildInfoExecutor() : AsyncRequestExecutor("BuildInfoExecutor") {}
+
+ Status handleRequest(std::shared_ptr<RequestExecutionContext> rec) {
+ auto result = rec->getReplyBuilder()->getBodyBuilder();
+ VersionInfoInterface::instance().appendBuildInfo(&result);
+ appendStorageEngineList(rec->getOpCtx()->getServiceContext(), &result);
+ return Status::OK();
+ }
+
+ static BuildInfoExecutor* get(ServiceContext* svc);
+};
+
+const auto getBuildInfoExecutor = ServiceContext::declareDecoration<BuildInfoExecutor>();
+BuildInfoExecutor* BuildInfoExecutor::get(ServiceContext* svc) {
+ return const_cast<BuildInfoExecutor*>(&getBuildInfoExecutor(svc));
+}
+
class CmdBuildInfo : public BasicCommand {
public:
CmdBuildInfo() : BasicCommand("buildInfo", "buildinfo") {}
@@ -816,6 +839,11 @@ public:
return true;
}
+ Future<void> runAsync(std::shared_ptr<RequestExecutionContext> rec, std::string) override {
+ auto opCtx = rec->getOpCtx();
+ return BuildInfoExecutor::get(opCtx->getServiceContext())->schedule(std::move(rec));
+ }
+
} cmdBuildInfo;
} // namespace