Skip to content

Commit 7ea935f

Browse files
authored
GODRIVER-2138 Remove unused opCtx param from Server.ProcessHandshakeError (#792)
1 parent 9fdc7d2 commit 7ea935f

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

x/mongo/driver/topology/connection.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ func newConnection(addr address.Address, opts ...ConnectionOption) (*connection,
102102
return c, nil
103103
}
104104

105-
func (c *connection) processInitializationError(opCtx context.Context, err error) {
105+
func (c *connection) processInitializationError(err error) {
106106
atomic.StoreInt64(&c.connected, disconnected)
107107
if c.nc != nil {
108108
_ = c.nc.Close()
109109
}
110110

111111
c.connectErr = ConnectionError{Wrapped: err, init: true}
112112
if c.config.errorHandlingCallback != nil {
113-
c.config.errorHandlingCallback(opCtx, c.connectErr, c.generation, c.desc.ServiceID)
113+
c.config.errorHandlingCallback(c.connectErr, c.generation, c.desc.ServiceID)
114114
}
115115
}
116116

@@ -185,7 +185,7 @@ func (c *connection) connect(ctx context.Context) {
185185
var tempNc net.Conn
186186
tempNc, err = c.config.dialer.DialContext(dialCtx, c.addr.Network(), c.addr.String())
187187
if err != nil {
188-
c.processInitializationError(ctx, err)
188+
c.processInitializationError(err)
189189
return
190190
}
191191
c.nc = tempNc
@@ -201,7 +201,7 @@ func (c *connection) connect(ctx context.Context) {
201201
}
202202
tlsNc, err := configureTLS(dialCtx, c.config.tlsConnectionSource, c.nc, c.addr, tlsConfig, ocspOpts)
203203
if err != nil {
204-
c.processInitializationError(ctx, err)
204+
c.processInitializationError(err)
205205
return
206206
}
207207
c.nc = tlsNc
@@ -247,7 +247,7 @@ func (c *connection) connect(ctx context.Context) {
247247

248248
// We have a failed handshake here
249249
if err != nil {
250-
c.processInitializationError(ctx, err)
250+
c.processInitializationError(err)
251251
return
252252
}
253253

x/mongo/driver/topology/connection_options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type connectionConfig struct {
5353
zstdLevel *int
5454
ocspCache ocsp.Cache
5555
disableOCSPEndpointCheck bool
56-
errorHandlingCallback func(opCtx context.Context, err error, startGenNum uint64, svcID *primitive.ObjectID)
56+
errorHandlingCallback func(err error, startGenNum uint64, svcID *primitive.ObjectID)
5757
tlsConnectionSource tlsConnectionSource
5858
loadBalanced bool
5959
getGenerationFn generationNumberFn
@@ -90,7 +90,7 @@ func withTLSConnectionSource(fn func(tlsConnectionSource) tlsConnectionSource) C
9090
}
9191
}
9292

93-
func withErrorHandlingCallback(fn func(opCtx context.Context, err error, startGenNum uint64, svcID *primitive.ObjectID)) ConnectionOption {
93+
func withErrorHandlingCallback(fn func(err error, startGenNum uint64, svcID *primitive.ObjectID)) ConnectionOption {
9494
return func(c *connectionConfig) error {
9595
c.errorHandlingCallback = fn
9696
return nil

x/mongo/driver/topology/connection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestConnection(t *testing.T) {
129129
return &net.TCPConn{}, nil
130130
})
131131
}),
132-
withErrorHandlingCallback(func(_ context.Context, err error, _ uint64, _ *primitive.ObjectID) {
132+
withErrorHandlingCallback(func(err error, _ uint64, _ *primitive.ObjectID) {
133133
got = err
134134
}),
135135
)

x/mongo/driver/topology/sdam_spec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func applyErrors(t *testing.T, topo *Topology, errors []applicationError) {
344344

345345
switch appErr.When {
346346
case "beforeHandshakeCompletes":
347-
server.ProcessHandshakeError(context.Background(), currError, generation, nil)
347+
server.ProcessHandshakeError(currError, generation, nil)
348348
case "afterHandshakeCompletes":
349349
_ = server.ProcessError(currError, &conn)
350350
default:

x/mongo/driver/topology/server.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,8 @@ func (s *Server) Connection(ctx context.Context) (driver.Connection, error) {
272272
}
273273

274274
// ProcessHandshakeError implements SDAM error handling for errors that occur before a connection
275-
// finishes handshaking. opCtx is the context passed to Server.Connection() and is used to determine
276-
// whether or not an operation-scoped context deadline or cancellation was the cause of the
277-
// handshake error; it is not used for timeout or cancellation of ProcessHandshakeError.
278-
// TODO(GODRIVER-2138): Remove unnecessary operation Context parameter after GODRIVER-2038.
279-
func (s *Server) ProcessHandshakeError(opCtx context.Context, err error, startingGenerationNumber uint64, serviceID *primitive.ObjectID) {
275+
// finishes handshaking.
276+
func (s *Server) ProcessHandshakeError(err error, startingGenerationNumber uint64, serviceID *primitive.ObjectID) {
280277
// Ignore the error if the server is behind a load balancer but the service ID is unknown. This indicates that the
281278
// error happened when dialing the connection or during the MongoDB handshake, so we don't know the service ID to
282279
// use for clearing the pool.

0 commit comments

Comments
 (0)