Skip to content

Commit 3fa059d

Browse files
GODRIVER-3173 Fix typos
1 parent 245945d commit 3fa059d

File tree

8 files changed

+82
-88
lines changed

8 files changed

+82
-88
lines changed

bson/default_value_encoders.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package bson
99
import (
1010
"encoding/json"
1111
"errors"
12-
"fmt"
1312
"math"
1413
"net/url"
1514
"reflect"
@@ -166,7 +165,6 @@ func decimal128EncodeValue(_ EncodeContext, vw ValueWriter, val reflect.Value) e
166165
if !val.IsValid() || val.Type() != tDecimal {
167166
return ValueEncoderError{Name: "Decimal128EncodeValue", Types: []reflect.Type{tDecimal}, Received: val}
168167
}
169-
fmt.Println(val.Interface().(Decimal128))
170168
return vw.WriteDecimal128(val.Interface().(Decimal128))
171169
}
172170

event/monitoring.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,10 @@ type PoolEvent struct {
108108
Reason string `json:"reason"`
109109
// ServiceID is only set if the Type is PoolCleared and the server is deployed behind a load balancer. This field
110110
// can be used to distinguish between individual servers in a load balanced deployment.
111-
ServiceID *bson.ObjectID `json:"serviceId"`
112-
Interruption bool `json:"interruptInUseConnections"`
113-
Error error `json:"error"`
114-
RequestID int32 `json:"requestId"`
115-
RemainingTime time.Duration `json:"remainingTime"`
111+
ServiceID *bson.ObjectID `json:"serviceId"`
112+
Interruption bool `json:"interruptInUseConnections"`
113+
Error error `json:"error"`
114+
RequestID int32 `json:"requestId"`
116115
}
117116

118117
// PoolMonitor is a function that allows the user to gain access to events occurring in the pool

internal/integration/csot_prose_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ func TestCSOTProse(t *testing.T) {
176176
time.Millisecond,
177177
"expected ping to fail within 150ms")
178178
})
179-
180179
})
181180

182181
mt.RunOpts("11. multi-batch bulkWrites", mtest.NewOptions().MinServerVersion("8.0").

internal/logger/component.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,35 @@ import (
1414
)
1515

1616
const (
17-
CommandFailed = "Command failed"
18-
CommandStarted = "Command started"
19-
CommandSucceeded = "Command succeeded"
20-
ConnectionPoolCreated = "Connection pool created"
21-
ConnectionPoolReady = "Connection pool ready"
22-
ConnectionPoolCleared = "Connection pool cleared"
23-
ConnectionPoolClosed = "Connection pool closed"
24-
ConnectionCreated = "Connection created"
25-
ConnectionReady = "Connection ready"
26-
ConnectionClosed = "Connection closed"
27-
ConnectionCheckoutStarted = "Connection checkout started"
28-
ConnectionCheckoutFailed = "Connection checkout failed"
29-
ConnectionCheckedOut = "Connection checked out"
30-
ConnectionCheckedIn = "Connection checked in"
31-
ConnectionPendingReadStarted = "Pending response started"
32-
ConnectionPendingReadSucceeded = "Pending response succeeded"
33-
ConnectionPendingReadFailed = "Pending response failed"
34-
ServerSelectionFailed = "Server selection failed"
35-
ServerSelectionStarted = "Server selection started"
36-
ServerSelectionSucceeded = "Server selection succeeded"
37-
ServerSelectionWaiting = "Waiting for suitable server to become available"
38-
TopologyClosed = "Stopped topology monitoring"
39-
TopologyDescriptionChanged = "Topology description changed"
40-
TopologyOpening = "Starting topology monitoring"
41-
TopologyServerClosed = "Stopped server monitoring"
42-
TopologyServerHeartbeatFailed = "Server heartbeat failed"
43-
TopologyServerHeartbeatStarted = "Server heartbeat started"
44-
TopologyServerHeartbeatSucceeded = "Server heartbeat succeeded"
45-
TopologyServerOpening = "Starting server monitoring"
17+
CommandFailed = "Command failed"
18+
CommandStarted = "Command started"
19+
CommandSucceeded = "Command succeeded"
20+
ConnectionPoolCreated = "Connection pool created"
21+
ConnectionPoolReady = "Connection pool ready"
22+
ConnectionPoolCleared = "Connection pool cleared"
23+
ConnectionPoolClosed = "Connection pool closed"
24+
ConnectionCreated = "Connection created"
25+
ConnectionReady = "Connection ready"
26+
ConnectionClosed = "Connection closed"
27+
ConnectionCheckoutStarted = "Connection checkout started"
28+
ConnectionCheckoutFailed = "Connection checkout failed"
29+
ConnectionCheckedOut = "Connection checked out"
30+
ConnectionCheckedIn = "Connection checked in"
31+
ConnectionPendingResponseStarted = "Pending response started"
32+
ConnectionPendingResponseSucceeded = "Pending response succeeded"
33+
ConnectionPendingResponseFailed = "Pending response failed"
34+
ServerSelectionFailed = "Server selection failed"
35+
ServerSelectionStarted = "Server selection started"
36+
ServerSelectionSucceeded = "Server selection succeeded"
37+
ServerSelectionWaiting = "Waiting for suitable server to become available"
38+
TopologyClosed = "Stopped topology monitoring"
39+
TopologyDescriptionChanged = "Topology description changed"
40+
TopologyOpening = "Starting topology monitoring"
41+
TopologyServerClosed = "Stopped server monitoring"
42+
TopologyServerHeartbeatFailed = "Server heartbeat failed"
43+
TopologyServerHeartbeatStarted = "Server heartbeat started"
44+
TopologyServerHeartbeatSucceeded = "Server heartbeat succeeded"
45+
TopologyServerOpening = "Starting server monitoring"
4646
)
4747

4848
const (

x/mongo/driver/topology/cmap_prose_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func TestCMAPProse(t *testing.T) {
272272

273273
// Need to test the case where we attempt a non-blocking read to determine if
274274
// we should refresh the remaining time. In the case of the Go Driver, we do
275-
// this by attempt to "pee" at 1 byte with a deadline of 1ns.
275+
// this by attempt to "peek" at 1 byte with a deadline of 1ns.
276276
t.Run("connection attempts peek but fails", func(t *testing.T) {
277277
const requestID = int32(-1)
278278
timeout := 10 * time.Millisecond
@@ -342,7 +342,7 @@ func TestCMAPProse(t *testing.T) {
342342
time.Sleep(3 * time.Second)
343343

344344
// Check out the connection again. The remaining time should be exhausted
345-
// requiring us to "peek" at the connection to determine if we should
345+
// requiring us to "peek" at the connection to determine if we should.
346346
_, err = p.checkOut(context.Background())
347347
assert.ErrorIs(t, err, io.EOF)
348348

@@ -363,7 +363,6 @@ func TestCMAPProse(t *testing.T) {
363363
assert.Equal(t, requestID, failed[0].RequestID)
364364
assert.Equal(t, "error", failed[0].Reason)
365365
assert.ErrorIs(t, failed[0].Error, io.EOF)
366-
assert.Equal(t, time.Duration(0), failed[0].RemainingTime)
367366

368367
// There should be 0 ConnectionPendingResponseSucceeded event.
369368
require.Len(t, poolEventsByType[event.ConnectionPendingResponseSucceeded], 0)
@@ -442,6 +441,7 @@ func TestCMAPProse(t *testing.T) {
442441

443442
// Check out the connection again. The remaining time should be exhausted
444443
// requiring us to "peek" at the connection to determine if we should
444+
// close as not alive.
445445
_, err = p.checkOut(context.Background())
446446
require.NoError(t, err)
447447

x/mongo/driver/topology/connection.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var (
4747

4848
func nextConnectionID() uint64 { return atomic.AddUint64(&globalConnectionID, 1) }
4949

50-
type pendingReadState struct {
50+
type pendingResponseState struct {
5151
remainingBytes int32
5252
requestID int32
5353
start time.Time
@@ -88,11 +88,11 @@ type connection struct {
8888
// accessTokens in the OIDC authenticator cache.
8989
oidcTokenGenID uint64
9090

91-
// pendingReadState contains information required to attempt a pending read
91+
// pendingResponseState contains information required to attempt a pending read
9292
// in the event of a socket timeout for an operation that has appended
9393
// maxTimeMS to the wire message.
94-
pendingReadState *pendingReadState
95-
pendingReadMu sync.Mutex
94+
pendingResponseState *pendingResponseState
95+
pendingResponseStateMu sync.Mutex
9696
}
9797

9898
// newConnection handles the creation of a connection. It does not connect the connection.
@@ -415,14 +415,14 @@ func (c *connection) readWireMessage(ctx context.Context) ([]byte, error) {
415415

416416
dst, errMsg, err := c.read(ctx)
417417
if err != nil {
418-
c.pendingReadMu.Lock()
419-
if c.pendingReadState == nil {
418+
c.pendingResponseStateMu.Lock()
419+
if c.pendingResponseState == nil {
420420
// If there is no pending read on the connection, use the pre-CSOT
421421
// behavior and close the connection because we don't know if there are
422422
// other bytes left to read.
423423
c.close()
424424
}
425-
c.pendingReadMu.Unlock()
425+
c.pendingResponseStateMu.Unlock()
426426
message := errMsg
427427
if errors.Is(err, io.EOF) {
428428
message = "socket was unexpectedly closed"
@@ -490,7 +490,7 @@ func (c *connection) read(ctx context.Context) (bytesRead []byte, errMsg string,
490490
if l := int32(n); l == 0 && isCSOTTimeout(err) && driverutil.HasMaxTimeMS(ctx) {
491491
requestID, _ := driverutil.GetRequestID(ctx)
492492

493-
c.pendingReadState = &pendingReadState{
493+
c.pendingResponseState = &pendingResponseState{
494494
remainingBytes: l,
495495
requestID: requestID,
496496
start: time.Now(),
@@ -512,7 +512,7 @@ func (c *connection) read(ctx context.Context) (bytesRead []byte, errMsg string,
512512
if remainingBytes > 0 && isCSOTTimeout(err) && driverutil.HasMaxTimeMS(ctx) {
513513
requestID, _ := driverutil.GetRequestID(ctx)
514514

515-
c.pendingReadState = &pendingReadState{
515+
c.pendingResponseState = &pendingResponseState{
516516
remainingBytes: remainingBytes,
517517
requestID: requestID,
518518
start: time.Now(),

x/mongo/driver/topology/pool.go

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ func (p *pool) checkOut(ctx context.Context) (conn *connection, err error) {
578578
return nil, w.err
579579
}
580580

581-
if err := awaitPendingRead(ctx, p, w.conn); err != nil {
581+
if err := awaitPendingResponse(ctx, p, w.conn); err != nil {
582582
return nil, err
583583
}
584584

@@ -638,7 +638,7 @@ func (p *pool) checkOut(ctx context.Context) (conn *connection, err error) {
638638
return nil, w.err
639639
}
640640

641-
if err := awaitPendingRead(ctx, p, w.conn); err != nil {
641+
if err := awaitPendingResponse(ctx, p, w.conn); err != nil {
642642
return nil, err
643643
}
644644

@@ -781,19 +781,18 @@ func (p *pool) removeConnection(conn *connection, reason reason, err error) erro
781781
return nil
782782
}
783783

784-
// PendingReadTimeout is the maximum amount of the to wait when trying to read
785-
// the server reply on a connection after an operation timed out. The
786-
// default is 400 milliseconds. This value is refreshed for every 4KB read from
787-
// the TCP stream.
784+
// PendingResponseTimeout is the maximum amount of the to wait when trying to
785+
// read the server reply on a connection after an operation timed out. The
786+
// default is 3000 milliseconds.
788787
//
789-
// Deprecated: PendingReadTimeout is intended for internal use only and may be
790-
// removed or modified at any time.
791-
var PendingReadTimeout = 3000 * time.Millisecond
788+
// Deprecated: PendingResponseTimeout is intended for internal use only and may
789+
// be removed or modified at any time.
790+
var PendingResponseTimeout = 3000 * time.Millisecond
792791

793-
// publishPendingReadStarted will log a message to the pool logger and
792+
// publishPendingResponseStarted will log a message to the pool logger and
794793
// publish an event to the pool monitor if they are set.
795-
func publishPendingReadStarted(pool *pool, conn *connection) {
796-
prs := conn.pendingReadState
794+
func publishPendingResponseStarted(pool *pool, conn *connection) {
795+
prs := conn.pendingResponseState
797796
if prs == nil {
798797
return
799798
}
@@ -805,7 +804,7 @@ func publishPendingReadStarted(pool *pool, conn *connection) {
805804
logger.KeyRequestID, prs.requestID,
806805
}
807806

808-
logPoolMessage(pool, logger.ConnectionPendingReadStarted, keysAndValues...)
807+
logPoolMessage(pool, logger.ConnectionPendingResponseStarted, keysAndValues...)
809808
}
810809

811810
// publish an event to the pool monitor if it is set.
@@ -821,8 +820,8 @@ func publishPendingReadStarted(pool *pool, conn *connection) {
821820
}
822821
}
823822

824-
func publishPendingReadFailed(pool *pool, conn *connection, err error) {
825-
prs := conn.pendingReadState
823+
func publishPendingResponseFailed(pool *pool, conn *connection, err error) {
824+
prs := conn.pendingResponseState
826825
if prs == nil {
827826
return
828827
}
@@ -840,7 +839,7 @@ func publishPendingReadFailed(pool *pool, conn *connection, err error) {
840839
logger.KeyError, err.Error(),
841840
}
842841

843-
logPoolMessage(pool, logger.ConnectionPendingReadFailed, keysAndValues...)
842+
logPoolMessage(pool, logger.ConnectionPendingResponseFailed, keysAndValues...)
844843
}
845844

846845
if pool.monitor != nil {
@@ -856,8 +855,8 @@ func publishPendingReadFailed(pool *pool, conn *connection, err error) {
856855
}
857856
}
858857

859-
func publishPendingReadSucceeded(pool *pool, conn *connection, dur time.Duration) {
860-
prs := conn.pendingReadState
858+
func publishPendingResponseSucceeded(pool *pool, conn *connection, dur time.Duration) {
859+
prs := conn.pendingResponseState
861860
if prs == nil {
862861
return
863862
}
@@ -869,7 +868,7 @@ func publishPendingReadSucceeded(pool *pool, conn *connection, dur time.Duration
869868
logger.KeyDurationMS, dur.Milliseconds(),
870869
}
871870

872-
logPoolMessage(pool, logger.ConnectionPendingReadSucceeded, keysAndValues...)
871+
logPoolMessage(pool, logger.ConnectionPendingResponseSucceeded, keysAndValues...)
873872
}
874873

875874
if pool.monitor != nil {
@@ -901,8 +900,8 @@ func peekConnectionAlive(conn *connection) (int, error) {
901900
return len(bytes), err
902901
}
903902

904-
func attemptPendingRead(ctx context.Context, conn *connection, remainingTime time.Duration) (int, error) {
905-
pendingreadState := conn.pendingReadState
903+
func attemptPendingResponse(ctx context.Context, conn *connection, remainingTime time.Duration) (int, error) {
904+
pendingreadState := conn.pendingResponseState
906905
if pendingreadState == nil {
907906
return 0, fmt.Errorf("no pending read state")
908907
}
@@ -986,25 +985,25 @@ func attemptPendingRead(ctx context.Context, conn *connection, remainingTime tim
986985
return int(totalRead), nil
987986
}
988987

989-
// awaitPendingRead sets a new read deadline on the provided connection and
988+
// awaitPendingResponse sets a new read deadline on the provided connection and
990989
// tries to read any bytes returned by the server. If there are any errors, the
991990
// connection will be checked back into the pool to be retried.
992-
func awaitPendingRead(ctx context.Context, pool *pool, conn *connection) error {
993-
conn.pendingReadMu.Lock()
994-
defer conn.pendingReadMu.Unlock()
991+
func awaitPendingResponse(ctx context.Context, pool *pool, conn *connection) error {
992+
conn.pendingResponseStateMu.Lock()
993+
defer conn.pendingResponseStateMu.Unlock()
995994

996995
// If there are no bytes pending read, do nothing.
997-
if conn.pendingReadState == nil {
996+
if conn.pendingResponseState == nil {
998997
return nil
999998
}
1000999

1001-
publishPendingReadStarted(pool, conn)
1000+
publishPendingResponseStarted(pool, conn)
10021001

10031002
var (
1004-
pendingReadState = conn.pendingReadState
1005-
remainingTime = pendingReadState.start.Add(PendingReadTimeout).Sub(time.Now())
1006-
err error
1007-
bytesRead int
1003+
pendingResponseState = conn.pendingResponseState
1004+
remainingTime = pendingResponseState.start.Add(PendingResponseTimeout).Sub(time.Now())
1005+
err error
1006+
bytesRead int
10081007
)
10091008

10101009
st := time.Now()
@@ -1013,7 +1012,7 @@ func awaitPendingRead(ctx context.Context, pool *pool, conn *connection) error {
10131012
// aliveness. In such cases, we don't want to close the connection.
10141013
bytesRead, err = peekConnectionAlive(conn)
10151014
} else {
1016-
bytesRead, err = attemptPendingRead(ctx, conn, remainingTime)
1015+
bytesRead, err = attemptPendingResponse(ctx, conn, remainingTime)
10171016
}
10181017

10191018
endTime := time.Now()
@@ -1029,13 +1028,12 @@ func awaitPendingRead(ctx context.Context, pool *pool, conn *connection) error {
10291028
// operations. This is likely a bug in the Go Driver. So it's possible that
10301029
// the connection is idle at the point of check-in.
10311030
defer func() {
1032-
publishPendingReadFailed(pool, conn, err)
1031+
publishPendingResponseFailed(pool, conn, err)
10331032

10341033
_ = pool.checkInNoEvent(conn)
10351034
}()
10361035

10371036
if netErr, ok := err.(net.Error); ok && !netErr.Timeout() {
1038-
fmt.Println(1)
10391037
if err := conn.close(); err != nil {
10401038
return err
10411039
}
@@ -1045,11 +1043,11 @@ func awaitPendingRead(ctx context.Context, pool *pool, conn *connection) error {
10451043

10461044
// If the read was successful, then we should refresh the remaining timeout.
10471045
if bytesRead > 0 {
1048-
pendingReadState.start = endTime
1046+
pendingResponseState.start = endTime
10491047
}
10501048

10511049
// If the remaining time has been exceeded, then close the connection.
1052-
if endTime.Sub(pendingReadState.start) > PendingReadTimeout {
1050+
if endTime.Sub(pendingResponseState.start) > PendingResponseTimeout {
10531051
if err := conn.close(); err != nil {
10541052
return err
10551053
}
@@ -1059,9 +1057,9 @@ func awaitPendingRead(ctx context.Context, pool *pool, conn *connection) error {
10591057
return err
10601058
}
10611059

1062-
publishPendingReadSucceeded(pool, conn, endDuration)
1060+
publishPendingResponseSucceeded(pool, conn, endDuration)
10631061

1064-
conn.pendingReadState = nil
1062+
conn.pendingResponseState = nil
10651063

10661064
return nil
10671065
}

0 commit comments

Comments
 (0)