summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/rpc/metadata.cpp6
-rw-r--r--src/mongo/rpc/metadata/server_selection_metadata.cpp9
-rw-r--r--src/mongo/rpc/metadata/server_selection_metadata.h13
-rw-r--r--src/mongo/rpc/metadata/server_selection_metadata_test.cpp2
4 files changed, 12 insertions, 18 deletions
diff --git a/src/mongo/rpc/metadata.cpp b/src/mongo/rpc/metadata.cpp
index e7725dd4a74..c65953790ec 100644
--- a/src/mongo/rpc/metadata.cpp
+++ b/src/mongo/rpc/metadata.cpp
@@ -55,14 +55,12 @@ namespace rpc {
return swAuditMetadata.getStatus();
}
AuditMetadata::get(txn) = std::move(swAuditMetadata.getValue());
+
return Status::OK();
}
Status writeRequestMetadata(OperationContext* txn, BSONObjBuilder* metadataBob) {
- auto ssStatus = ServerSelectionMetadata::writeToMetadata(
- ServerSelectionMetadata::get(txn),
- metadataBob
- );
+ auto ssStatus = ServerSelectionMetadata::get(txn).writeToMetadata(metadataBob);
if (!ssStatus.isOK()) {
return ssStatus;
}
diff --git a/src/mongo/rpc/metadata/server_selection_metadata.cpp b/src/mongo/rpc/metadata/server_selection_metadata.cpp
index ffa576e5de6..4222c88e895 100644
--- a/src/mongo/rpc/metadata/server_selection_metadata.cpp
+++ b/src/mongo/rpc/metadata/server_selection_metadata.cpp
@@ -177,14 +177,13 @@ namespace {
return ServerSelectionMetadata(secondaryOk, std::move(readPreference));
}
- Status ServerSelectionMetadata::writeToMetadata(const ServerSelectionMetadata& ss,
- BSONObjBuilder* metadataBob) {
- if (ss.isSecondaryOk()) {
+ Status ServerSelectionMetadata::writeToMetadata(BSONObjBuilder* metadataBob) const {
+ if (isSecondaryOk()) {
metadataBob->append(kSecondaryOkFieldName, 1);
}
- if (ss.getReadPreference()) {
- metadataBob->append(kReadPreferenceFieldName, ss.getReadPreference()->toBSON());
+ if (getReadPreference()) {
+ metadataBob->append(kReadPreferenceFieldName, getReadPreference()->toBSON());
}
return Status::OK();
diff --git a/src/mongo/rpc/metadata/server_selection_metadata.h b/src/mongo/rpc/metadata/server_selection_metadata.h
index 93ba352f317..4bdc700f20b 100644
--- a/src/mongo/rpc/metadata/server_selection_metadata.h
+++ b/src/mongo/rpc/metadata/server_selection_metadata.h
@@ -65,20 +65,18 @@ namespace rpc {
#endif
/**
- * Loads ServerSelectionMetadata from a metadata object and stores it on this
- * OperationContext.
+ * Loads ServerSelectionMetadata from a metadata object.
*/
static StatusWith<ServerSelectionMetadata> readFromMetadata(const BSONObj& metadataObj);
/**
* Writes this operation's ServerSelectionMetadata to a metadata object.
*/
- static Status writeToMetadata(const ServerSelectionMetadata& ss,
- BSONObjBuilder* metadataBob);
+ Status writeToMetadata(BSONObjBuilder* metadataBob) const;
/**
- * Rewrites the ServerSelectionMetadata from the legacy OP_QUERY format to the metadata
- * object format. In particular, if secondaryOk is set, this will set QueryOption_SlaveOk
+ * Rewrites the ServerSelectionMetadata from the metadata object format to the legacy OP_QUERY
+ * format. In particular, if secondaryOk is set, this will set QueryOption_SlaveOk
* on the legacyQueryFlags. If a readPreference is set, the legacy command will be wrapped
* in a 'query' element and a top-level $readPreference field will be set on the command.
*/
@@ -107,10 +105,9 @@ namespace rpc {
*/
const boost::optional<ReadPreferenceSetting>& getReadPreference() const;
- private:
ServerSelectionMetadata(bool secondaryOk,
boost::optional<ReadPreferenceSetting> readPreference);
-
+ private:
bool _secondaryOk{false};
boost::optional<ReadPreferenceSetting> _readPreference{};
};
diff --git a/src/mongo/rpc/metadata/server_selection_metadata_test.cpp b/src/mongo/rpc/metadata/server_selection_metadata_test.cpp
index a87b246359a..fe6de217b46 100644
--- a/src/mongo/rpc/metadata/server_selection_metadata_test.cpp
+++ b/src/mongo/rpc/metadata/server_selection_metadata_test.cpp
@@ -172,4 +172,4 @@ namespace {
ErrorCodes::NoSuchKey);
}
-}
+} // namespace