diff options
author | Kevin Pulo <kevin.pulo@mongodb.com> | 2020-02-20 21:42:07 +1100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-05 13:03:43 +0000 |
commit | 747ff353cbc819d032fa727d4bd7ffad16ea0437 (patch) | |
tree | d9b3d7e9af26138d7b74e0416a93d6110e326af0 /src/mongo/client/dbclient_base.h | |
parent | 7c4b875a8858c5bd5efc9bf4f285f7f440fdfdc0 (diff) | |
download | mongo-747ff353cbc819d032fa727d4bd7ffad16ea0437.tar.gz |
SERVER-45692 add explicit RWC to inter-node commands (even if merely kImplicitDefault)
Diffstat (limited to 'src/mongo/client/dbclient_base.h')
-rw-r--r-- | src/mongo/client/dbclient_base.h | 129 |
1 files changed, 87 insertions, 42 deletions
diff --git a/src/mongo/client/dbclient_base.h b/src/mongo/client/dbclient_base.h index 5a3dfcfc766..5db09d9412e 100644 --- a/src/mongo/client/dbclient_base.h +++ b/src/mongo/client/dbclient_base.h @@ -73,27 +73,31 @@ std::string nsGetCollection(const std::string& ns); * them as "final" or "override" as appropriate. */ class DBClientQueryInterface { - virtual std::unique_ptr<DBClientCursor> query(const NamespaceStringOrUUID& nsOrUuid, - Query query, - int nToReturn = 0, - int nToSkip = 0, - const BSONObj* fieldsToReturn = nullptr, - int queryOptions = 0, - int batchSize = 0) = 0; + virtual std::unique_ptr<DBClientCursor> query( + const NamespaceStringOrUUID& nsOrUuid, + Query query, + int nToReturn = 0, + int nToSkip = 0, + const BSONObj* fieldsToReturn = nullptr, + int queryOptions = 0, + int batchSize = 0, + boost::optional<BSONObj> readConcernObj = boost::none) = 0; virtual unsigned long long query(std::function<void(const BSONObj&)> f, const NamespaceStringOrUUID& nsOrUuid, Query query, const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, - int batchSize = 0) = 0; + int batchSize = 0, + boost::optional<BSONObj> readConcernObj = boost::none) = 0; virtual unsigned long long query(std::function<void(DBClientCursorBatchIterator&)> f, const NamespaceStringOrUUID& nsOrUuid, Query query, const BSONObj* fieldsToReturn = nullptr, int queryOptions = 0, - int batchSize = 0) = 0; + int batchSize = 0, + boost::optional<BSONObj> readConcernObj = boost::none) = 0; }; /** @@ -119,7 +123,8 @@ public: virtual BSONObj findOne(const std::string& ns, const Query& query, const BSONObj* fieldsToReturn = nullptr, - int queryOptions = 0); + int queryOptions = 0, + boost::optional<BSONObj> readConcernObj = boost::none); /** query N objects from the database into an array. makes sense mostly when you want a small * number of results. if a huge number, use query() and iterate the cursor. @@ -130,7 +135,8 @@ public: int nToReturn, int nToSkip = 0, const BSONObj* fieldsToReturn = nullptr, - int queryOptions = 0); + int queryOptions = 0, + boost::optional<BSONObj> readConcernObj = boost::none); /** * @return a pair with a single object that matches the filter within the collection specified @@ -140,9 +146,11 @@ public: * the query, an empty BSONObj is returned. * @throws AssertionException */ - virtual std::pair<BSONObj, NamespaceString> findOneByUUID(const std::string& db, - UUID uuid, - const BSONObj& filter); + virtual std::pair<BSONObj, NamespaceString> findOneByUUID( + const std::string& db, + UUID uuid, + const BSONObj& filter, + boost::optional<BSONObj> readConcernObj = boost::none); virtual std::string getServerAddress() const = 0; @@ -351,11 +359,12 @@ public: /** count number of objects in collection ns that match the query criteria specified throws UserAssertion if database returns an error */ - virtual long long count(NamespaceStringOrUUID nsOrUuid, + virtual long long count(const NamespaceStringOrUUID nsOrUuid, const BSONObj& query = BSONObj(), int options = 0, int limit = 0, - int skip = 0); + int skip = 0, + boost::optional<BSONObj> readConcernObj = boost::none); static std::string createPasswordDigest(const std::string& username, const std::string& clearTextPassword); @@ -390,7 +399,8 @@ public: long long size = 0, bool capped = false, int max = 0, - BSONObj* info = nullptr); + BSONObj* info = nullptr, + boost::optional<BSONObj> writeConcernObj = boost::none); /** Get error result from the last write operation (insert/update/delete) on this connection. db doesn't change the command's behavior - it is just for auth checks. @@ -483,8 +493,10 @@ public: * @param keys Document describing keys and index types. You must provide at least one * field and its direction. */ - void createIndex(StringData ns, const BSONObj& keys) { - return createIndex(ns, IndexSpec().addKeys(keys)); + void createIndex(StringData ns, + const BSONObj& keys, + boost::optional<BSONObj> writeConcernObj = boost::none) { + return createIndex(ns, IndexSpec().addKeys(keys), writeConcernObj); } /** Create an index on the collection 'ns' as described by the given @@ -495,20 +507,26 @@ public: * @param descriptor Configuration object describing the index to create. The * descriptor must describe at least one key and index type. */ - virtual void createIndex(StringData ns, const IndexSpec& descriptor) { + virtual void createIndex(StringData ns, + const IndexSpec& descriptor, + boost::optional<BSONObj> writeConcernObj = boost::none) { std::vector<const IndexSpec*> toBuild; toBuild.push_back(&descriptor); - createIndexes(ns, toBuild); + createIndexes(ns, toBuild, writeConcernObj); } - virtual void createIndexes(StringData ns, const std::vector<const IndexSpec*>& descriptor); + virtual void createIndexes(StringData ns, + const std::vector<const IndexSpec*>& descriptor, + boost::optional<BSONObj> writeConcernObj = boost::none); /** * Creates indexes on the collection 'ns' as described by 'specs'. * * Failure to construct the indexes is reported by throwing an AssertionException. */ - virtual void createIndexes(StringData ns, const std::vector<BSONObj>& specs); + virtual void createIndexes(StringData ns, + const std::vector<BSONObj>& specs, + boost::optional<BSONObj> writeConcernObj = boost::none); /** * Lists indexes on the collection 'nsOrUuid'. @@ -523,13 +541,18 @@ public: virtual std::list<BSONObj> getReadyIndexSpecs(const NamespaceStringOrUUID& nsOrUuid, int options = 0); - virtual void dropIndex(const std::string& ns, BSONObj keys); - virtual void dropIndex(const std::string& ns, const std::string& indexName); + virtual void dropIndex(const std::string& ns, + BSONObj keys, + boost::optional<BSONObj> writeConcernObj = boost::none); + virtual void dropIndex(const std::string& ns, + const std::string& indexName, + boost::optional<BSONObj> writeConcernObj = boost::none); /** drops all indexes for the collection */ - virtual void dropIndexes(const std::string& ns); + virtual void dropIndexes(const std::string& ns, + boost::optional<BSONObj> writeConcernObj = boost::none); virtual void reIndex(const std::string& ns); @@ -600,13 +623,15 @@ public: @return cursor. 0 if error (connection failure) @throws AssertionException */ - std::unique_ptr<DBClientCursor> query(const NamespaceStringOrUUID& nsOrUuid, - Query query, - int nToReturn = 0, - int nToSkip = 0, - const BSONObj* fieldsToReturn = nullptr, - int queryOptions = 0, - int batchSize = 0) override; + std::unique_ptr<DBClientCursor> query( + const NamespaceStringOrUUID& nsOrUuid, + Query query, + int nToReturn = 0, + int nToSkip = 0, + const BSONObj* fieldsToReturn = nullptr, + int queryOptions = 0, + int batchSize = 0, + boost::optional<BSONObj> readConcernObj = boost::none) override; /** Uses QueryOption_Exhaust, when available and specified in 'queryOptions'. @@ -628,14 +653,16 @@ public: Query query, const BSONObj* fieldsToReturn = nullptr, int queryOptions = QueryOption_Exhaust, - int batchSize = 0) final; + int batchSize = 0, + boost::optional<BSONObj> readConcernObj = boost::none) final; unsigned long long query(std::function<void(DBClientCursorBatchIterator&)> f, const NamespaceStringOrUUID& nsOrUuid, Query query, const BSONObj* fieldsToReturn = nullptr, int queryOptions = QueryOption_Exhaust, - int batchSize = 0) override; + int batchSize = 0, + boost::optional<BSONObj> readConcernObj = boost::none) override; /** don't use this - called automatically by DBClientCursor for you @@ -651,22 +678,39 @@ public: /** insert an object into the database */ - virtual void insert(const std::string& ns, BSONObj obj, int flags = 0); + virtual void insert(const std::string& ns, + BSONObj obj, + int flags = 0, + boost::optional<BSONObj> writeConcernObj = boost::none); /** insert a vector of objects into the database */ - virtual void insert(const std::string& ns, const std::vector<BSONObj>& v, int flags = 0); + virtual void insert(const std::string& ns, + const std::vector<BSONObj>& v, + int flags = 0, + boost::optional<BSONObj> writeConcernObj = boost::none); /** updates objects matching query */ - virtual void update( - const std::string& ns, Query query, BSONObj obj, bool upsert = false, bool multi = false); + virtual void update(const std::string& ns, + Query query, + BSONObj obj, + bool upsert = false, + bool multi = false, + boost::optional<BSONObj> writeConcernObj = boost::none); - virtual void update(const std::string& ns, Query query, BSONObj obj, int flags); + virtual void update(const std::string& ns, + Query query, + BSONObj obj, + int flags, + boost::optional<BSONObj> writeConcernObj = boost::none); - virtual void remove(const std::string& ns, Query query, int flags = 0); + virtual void remove(const std::string& ns, + Query query, + int flags = 0, + boost::optional<BSONObj> writeConcernObj = boost::none); virtual bool isFailed() const = 0; @@ -716,7 +760,8 @@ protected: const BSONObj& query, int options, int limit, - int skip); + int skip, + boost::optional<BSONObj> readConcernObj); /** * Look up the options available on this client. Caches the answer from |