summaryrefslogtreecommitdiff
path: root/src/mongo/db/write_concern.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-11-28 00:21:23 -0500
committerEliot Horowitz <eliot@10gen.com>2013-12-03 21:24:55 -0500
commitff4308beb1716d245779effef81acdef7686cc2c (patch)
tree428629cfd2140072377d66738348944f3f5f8b92 /src/mongo/db/write_concern.h
parent4fa4012a60147450b8c201ebb90687596fe673d5 (diff)
downloadmongo-ff4308beb1716d245779effef81acdef7686cc2c.tar.gz
SERVER-11665: refactor waitForWriteConcern
new structs instead of BSONObj
Diffstat (limited to 'src/mongo/db/write_concern.h')
-rw-r--r--src/mongo/db/write_concern.h59
1 files changed, 49 insertions, 10 deletions
diff --git a/src/mongo/db/write_concern.h b/src/mongo/db/write_concern.h
index 52dd0b0511e..e5cb4138d87 100644
--- a/src/mongo/db/write_concern.h
+++ b/src/mongo/db/write_concern.h
@@ -30,15 +30,54 @@
namespace mongo {
- /**
- * Helper method for commands to call. Blocks until write concern (as specified in "cmdObj")
- * is satisfied. "err" should be set to true if the last operation succeeded, otherwise false.
- * "result" will be filled with write concern results. Returns false and sets "errmsg" on
- * failure.
- */
- bool waitForWriteConcern(const BSONObj& cmdObj,
- bool err,
- BSONObjBuilder* result,
- string* errmsg);
+ struct WriteConcernOptions {
+
+ WriteConcernOptions() { reset(); }
+
+ Status parse( const BSONObj& obj );
+
+ void reset() {
+ syncMode = NONE;
+ wNumNodes = 0;
+ wMode = "";
+ wTimeout = 0;
+ }
+
+ enum SyncMode { NONE, FSYNC, JOURNAL } syncMode;
+
+ int wNumNodes;
+ string wMode;
+
+ int wTimeout;
+
+ };
+
+ struct WriteConcernResult {
+ WriteConcernResult() {
+ reset();
+ }
+
+ void reset() {
+ fsyncFiles = -1;
+ wTimedOut = false;
+ wTime = -1;
+ err = "";
+ }
+
+ void appendTo( BSONObjBuilder* result ) const;
+
+ int fsyncFiles;
+
+ bool wTimedOut;
+ int wTime;
+ vector<BSONObj> writtenTo;
+
+ string err; // this is the old err field, should deprecate
+ };
+
+ Status waitForWriteConcern(Client& client,
+ const WriteConcernOptions& writeConcern,
+ WriteConcernResult* result );
+
} // namespace mongo