diff --git a/core/readconcern/readconcern.go b/core/readconcern/readconcern.go index 1b4862fb85..aa8d01a3fe 100644 --- a/core/readconcern/readconcern.go +++ b/core/readconcern/readconcern.go @@ -40,6 +40,17 @@ func Linearizable() *ReadConcern { return New(Level("linearizable")) } +// Available specifies that the query should return data from the instance with no guarantee +// that the data has been written to a majority of the replica set members (i.e. may be rolled back). +func Available() *ReadConcern { + return New(Level("available")) +} + +// Snapshot is only available for operations within multi-document transactions. +func Snapshot() *ReadConcern { + return New(Level("snapshot")) +} + // New constructs a new read concern from the given string. func New(options ...Option) *ReadConcern { concern := &ReadConcern{} diff --git a/data/read-write-concern/connection-string/read-concern.json b/data/read-write-concern/connection-string/read-concern.json index dd2b792b29..960b47f51d 100644 --- a/data/read-write-concern/connection-string/read-concern.json +++ b/data/read-write-concern/connection-string/read-concern.json @@ -24,6 +24,33 @@ "readConcern": { "level": "majority" } + }, + { + "description": "available specified", + "uri": "mongodb://localhost/?readConcernLevel=available", + "valid": true, + "warning": false, + "readConcern": { + "level": "available" + } + }, + { + "description": "snapshot specified", + "uri": "mongodb://localhost/?readConcernLevel=snapshot", + "valid": true, + "warning": false, + "readConcern": { + "level": "snapshot" + } + }, + { + "description": "linearizable specified", + "uri": "mongodb://localhost/?readConcernLevel=linearizable", + "valid": true, + "warning": false, + "readConcern": { + "level": "linearizable" + } } ] } diff --git a/data/read-write-concern/connection-string/read-concern.yml b/data/read-write-concern/connection-string/read-concern.yml index 1560763d43..65de3243ff 100644 --- a/data/read-write-concern/connection-string/read-concern.yml +++ b/data/read-write-concern/connection-string/read-concern.yml @@ -17,3 +17,21 @@ tests: valid: true warning: false readConcern: { level: "majority" } + - + description: "available specified" + uri: "mongodb://localhost?readConcernLevel=available" + valid: true + warning: false + readConcern: { level: "available" } + - + description: "snapshot specified" + uri: "mongodb://localhost?readConcernLevel=snapshot" + valid: true + warning: false + readConcern: { level: "snapshot" } + - + description: "linearizable specified" + uri: "mongodb://localhost?readConcernLevel=linearizable" + valid: true + warning: false + readConcern: { level: "linearizable" } \ No newline at end of file diff --git a/data/read-write-concern/document/read-concern.json b/data/read-write-concern/document/read-concern.json index ef2bafdf55..950954e0d7 100644 --- a/data/read-write-concern/document/read-concern.json +++ b/data/read-write-concern/document/read-concern.json @@ -28,6 +28,39 @@ "level": "local" }, "isServerDefault": false + }, + { + "description": "Available", + "valid": true, + "readConcern": { + "level": "available" + }, + "readConcernDocument": { + "level": "available" + }, + "isServerDefault": false + }, + { + "description": "Snapshot", + "valid": true, + "readConcern": { + "level": "snapshot" + }, + "readConcernDocument": { + "level": "snapshot" + }, + "isServerDefault": false + }, + { + "description": "Linearizable", + "valid": true, + "readConcern": { + "level": "linearizable" + }, + "readConcernDocument": { + "level": "linearizable" + }, + "isServerDefault": false } ] } diff --git a/data/read-write-concern/document/read-concern.yml b/data/read-write-concern/document/read-concern.yml index e20a2d24ec..70679151c0 100644 --- a/data/read-write-concern/document/read-concern.yml +++ b/data/read-write-concern/document/read-concern.yml @@ -16,4 +16,22 @@ tests: valid: true readConcern: { level: "local" } readConcernDocument: { level: "local" } + isServerDefault: false + - + description: "Available" + valid: true + readConcern: { level: "available" } + readConcernDocument: { level: "available" } + isServerDefault: false + - + description: "Snapshot" + valid: true + readConcern: { level: "snapshot" } + readConcernDocument: { level: "snapshot" } + isServerDefault: false + - + description: "Linearizable" + valid: true + readConcern: { level: "linearizable" } + readConcernDocument: { level: "linearizable" } isServerDefault: false \ No newline at end of file