From bc01259739d25d94b448b0f5b4ff3288a3b6f8b1 Mon Sep 17 00:00:00 2001 From: Kirollos Morkos Date: Mon, 20 Nov 2023 12:22:42 -0500 Subject: [PATCH] Expose SnapshotTime on Session (cherry picked from commit 1a8932b00206d73d52f4086cc42ccb134055e7f0) (cherry picked from commit 2ecb9981207560615ef6fc4d0c7d9abed285c41b) --- mongo/session.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mongo/session.go b/mongo/session.go index 97d17736af..8ba400c084 100644 --- a/mongo/session.go +++ b/mongo/session.go @@ -122,6 +122,10 @@ type Session interface { // OperationTime returns the current operation time document associated with the session. OperationTime() *primitive.Timestamp + // SnapshotTime returns the snapshot timestamp being used for the session. + // If the session is not a snapshot session, or no operations have run on the session yet, it will return nil. + SnapshotTime() *primitive.Timestamp + // Client the Client associated with the session. Client() *Client @@ -361,6 +365,11 @@ func (s *sessionImpl) OperationTime() *primitive.Timestamp { return s.clientSession.OperationTime } +// SnapshotTime implements the Session interface. +func (s *sessionImpl) SnapshotTime() *primitive.Timestamp { + return s.clientSession.SnapshotTime +} + // AdvanceOperationTime implements the Session interface. func (s *sessionImpl) AdvanceOperationTime(ts *primitive.Timestamp) error { return s.clientSession.AdvanceOperationTime(ts)