-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-5736: Expose atClusterTime parameter in snapshot sessions #1874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e9d3178
d5e8b3d
a46c3a7
763f950
69e0baf
43ab914
0b40cce
7678002
02114e0
b504123
8556b21
c9c5041
edd0371
56c1b0b
5f63a93
5aa0a58
c22e569
8499e96
3e96140
f2f6f1e
c1e8f25
ecbae5a
7ee46b2
ce2c1c3
3ffea71
fe35bcb
9c9880c
78751a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,16 +13,35 @@ | |||||||||||||||||||||||||||||||||||
| * limitations under the License. | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| using System; | ||||||||||||||||||||||||||||||||||||
| using System.Threading; | ||||||||||||||||||||||||||||||||||||
| using System.Threading.Tasks; | ||||||||||||||||||||||||||||||||||||
| using MongoDB.Bson; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| namespace MongoDB.Driver | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| // TODO: CSOT: Make it public when CSOT will be ready for GA | ||||||||||||||||||||||||||||||||||||
| internal static class IClientSessionExtensions | ||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||
| /// Extension methods for <see cref="IClientSession"/>. | ||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||
| public static class IClientSessionExtensions | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||
| /// Gets the snapshot time for a snapshot session. | ||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||
| /// <param name="session">The client session handle.</param> | ||||||||||||||||||||||||||||||||||||
| /// <returns>The snapshot time as a <see cref="BsonTimestamp"/>.</returns> | ||||||||||||||||||||||||||||||||||||
| /// <exception cref="InvalidOperationException">Thrown when the session is not a snapshot session.</exception> | ||||||||||||||||||||||||||||||||||||
| public static BsonTimestamp GetSnapshotTime(this IClientSession session) | ||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||
| var clientSessionHandle = (ClientSessionHandle)session; | ||||||||||||||||||||||||||||||||||||
| return clientSessionHandle.WrappedCoreSession.IsSnapshot ? | ||||||||||||||||||||||||||||||||||||
| clientSessionHandle.SnapshotTime | ||||||||||||||||||||||||||||||||||||
papafe marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
| : throw new InvalidOperationException("Cannot retrieve snapshot time from a non-snapshot session."); | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+39
|
||||||||||||||||||||||||||||||||||||
| public static BsonTimestamp GetSnapshotTime(this IClientSession session) | |
| { | |
| var clientSessionHandle = (ClientSessionHandle)session; | |
| return clientSessionHandle.WrappedCoreSession.IsSnapshot ? | |
| clientSessionHandle.SnapshotTime | |
| : throw new InvalidOperationException("Cannot retrieve snapshot time from a non-snapshot session."); | |
| /// <exception cref="NotSupportedException">Thrown when the session is not a <see cref="ClientSessionHandle"/>.</exception> | |
| public static BsonTimestamp GetSnapshotTime(this IClientSession session) | |
| { | |
| if (session is ClientSessionHandle clientSessionHandle) | |
| { | |
| return clientSessionHandle.WrappedCoreSession.IsSnapshot | |
| ? clientSessionHandle.SnapshotTime | |
| : throw new InvalidOperationException("Cannot retrieve snapshot time from a non-snapshot session."); | |
| } | |
| throw new NotSupportedException("GetSnapshotTime is only supported for sessions of type ClientSessionHandle."); |
Uh oh!
There was an error while loading. Please reload this page.