Skip to content

Commit 375f935

Browse files
committed
Resume gossiping cluster time when establishing connections.
1 parent 0126221 commit 375f935

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

x/mongo/driver/auth/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func (ah *authHandshaker) GetHandshakeInformation(
103103
AppName(ah.options.AppName).
104104
Compressors(ah.options.Compressors).
105105
SASLSupportedMechs(ah.options.DBUser).
106+
ClusterClock(ah.options.ClusterClock).
106107
ServerAPI(ah.options.ServerAPI).
107108
LoadBalanced(ah.options.LoadBalanced).
108109
OuterLibraryName(ah.options.OuterLibraryName).

x/mongo/driver/operation/hello.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"go.mongodb.org/mongo-driver/v2/x/mongo/driver"
2525
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/description"
2626
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/mnet"
27+
"go.mongodb.org/mongo-driver/v2/x/mongo/driver/session"
2728
)
2829

2930
// maxClientMetadataSize is the maximum size of the client metadata document
@@ -41,6 +42,7 @@ type Hello struct {
4142
compressors []string
4243
saslSupportedMechs string
4344
d driver.Deployment
45+
clock *session.ClusterClock
4446
speculativeAuth bsoncore.Document
4547
topologyVersion *description.TopologyVersion
4648
maxAwaitTimeMS *int64
@@ -67,6 +69,16 @@ func (h *Hello) AppName(appname string) *Hello {
6769
return h
6870
}
6971

72+
// ClusterClock sets the cluster clock for this operation.
73+
func (h *Hello) ClusterClock(clock *session.ClusterClock) *Hello {
74+
if h == nil {
75+
h = new(Hello)
76+
}
77+
78+
h.clock = clock
79+
return h
80+
}
81+
7082
// Compressors sets the compressors that can be used.
7183
func (h *Hello) Compressors(compressors []string) *Hello {
7284
h.compressors = compressors
@@ -615,6 +627,7 @@ func isLegacyHandshake(srvAPI *driver.ServerAPIOptions, loadbalanced bool) bool
615627

616628
func (h *Hello) createOperation() driver.Operation {
617629
op := driver.Operation{
630+
Clock: h.clock,
618631
CommandFn: h.command,
619632
Database: "admin",
620633
Deployment: h.d,
@@ -639,6 +652,7 @@ func (h *Hello) GetHandshakeInformation(ctx context.Context, _ address.Address,
639652
deployment := driver.SingleConnectionDeployment{C: conn}
640653

641654
op := driver.Operation{
655+
Clock: h.clock,
642656
CommandFn: h.handshakeCommand,
643657
Deployment: deployment,
644658
Database: "admin",

x/mongo/driver/topology/topology_options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ func NewConfigFromOptionsWithAuthenticator(opts *options.ClientOptions, clock *s
290290
return operation.NewHello().
291291
AppName(appName).
292292
Compressors(comps).
293+
ClusterClock(clock).
293294
ServerAPI(serverAPI).
294295
LoadBalanced(loadBalanced).
295296
OuterLibraryName(outerLibraryName).

0 commit comments

Comments
 (0)