From 1a8932b00206d73d52f4086cc42ccb134055e7f0 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 --- mongo/session.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mongo/session.go b/mongo/session.go index e276a1118d..5442de0b20 100644 --- a/mongo/session.go +++ b/mongo/session.go @@ -123,6 +123,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 @@ -362,6 +366,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)