Skip to content

Commit face9c5

Browse files
authored
PML-165: Increase default client operation timeout (#97)
1 parent 1d8c8e8 commit face9c5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

config/const.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const (
4444
DisconnectTimeout = 5 * time.Second
4545
// CloseCursorTimeout is the timeout duration for closing cursor.
4646
CloseCursorTimeout = 10 * time.Second
47+
// OperationTimeout is the timeout duration for MonngoDB client operations like
48+
// insert, update, delete, etc.
49+
OperationTimeout = 5 * time.Minute
4750
)
4851

4952
// Change stream and replication settings.

topo/connect.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"net/url"
66
"slices"
77
"strings"
8-
"time"
98

109
"go.mongodb.org/mongo-driver/v2/mongo"
1110
"go.mongodb.org/mongo-driver/v2/mongo/options"
@@ -59,7 +58,7 @@ func ConnectWithOptions(
5958
SetReadPreference(readpref.Primary()).
6059
SetReadConcern(readconcern.Majority()).
6160
SetWriteConcern(writeconcern.Majority()).
62-
SetTimeout(time.Minute)
61+
SetTimeout(config.OperationTimeout)
6362

6463
if connOpts != nil && connOpts.Compressors != nil {
6564
opts.SetCompressors(connOpts.Compressors)

0 commit comments

Comments
 (0)