...
1
2
3
4
5
6
7 package session
8
9 import (
10 "sync"
11
12 "go.mongodb.org/mongo-driver/bson"
13 )
14
15
16 type ClusterClock struct {
17 clusterTime bson.Raw
18 lock sync.Mutex
19 }
20
21
22 func (cc *ClusterClock) GetClusterTime() bson.Raw {
23 var ct bson.Raw
24 cc.lock.Lock()
25 ct = cc.clusterTime
26 cc.lock.Unlock()
27
28 return ct
29 }
30
31
32 func (cc *ClusterClock) AdvanceClusterTime(clusterTime bson.Raw) {
33 cc.lock.Lock()
34 cc.clusterTime = MaxClusterTime(cc.clusterTime, clusterTime)
35 cc.lock.Unlock()
36 }
37
View as plain text