Skip to content

Commit e095f2d

Browse files
benjirewisBenjamin Rewis
authored andcommitted
GODRIVER-2495 Undeprecate legacy timeouts. (#1026)
Uses NOTEs to suggest that users use Timeout instead of legacy timeout options as opposed to deprecating legacy timeout options.
1 parent 18da11c commit e095f2d

11 files changed

+108
-106
lines changed

mongo/options/aggregateoptions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ type AggregateOptions struct {
3535
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
3636
// is no time limit for query execution.
3737
//
38-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
39-
// Timeout option should be used in its place to control the amount of time that the Aggregate operation can run before
40-
// returning an error. MaxTime is still usable through the deprecated setter.
38+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used
39+
// in its place to control the amount of time that a single operation can run before returning an error. MaxTime
40+
// is ignored if Timeout is set on the client.
4141
MaxTime *time.Duration
4242

4343
// The maximum amount of time that the server should wait for new documents to satisfy a tailable cursor query.
@@ -96,9 +96,9 @@ func (ao *AggregateOptions) SetCollation(c *Collation) *AggregateOptions {
9696

9797
// SetMaxTime sets the value for the MaxTime field.
9898
//
99-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver.
100-
// The more general Timeout option should be used in its place to control the amount of time that the
101-
// Aggregate operation can run before returning an error.
99+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
100+
// option may be used in its place to control the amount of time that a single operation can
101+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
102102
func (ao *AggregateOptions) SetMaxTime(d time.Duration) *AggregateOptions {
103103
ao.MaxTime = &d
104104
return ao

mongo/options/clientoptions.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ type ClientOptions struct {
154154

155155
// SocketTimeout specifies the timeout to be used for the Client's socket reads and writes.
156156
//
157-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
158-
// Timeout option should be used in its place to control the amount of time that a single operation can run on the Client
159-
// before returning an error. SocketTimeout is still usable through the deprecated setter.
157+
// NOTE(benjirewis): SocketTimeout will be deprecated in a future release. The more general Timeout option
158+
// may be used in its place to control the amount of time that a single operation can run before returning
159+
// an error. Setting SocketTimeout and Timeout on a single client will result in undefined behavior.
160160
SocketTimeout *time.Duration
161161
}
162162

@@ -715,9 +715,9 @@ func (c *ClientOptions) SetServerSelectionTimeout(d time.Duration) *ClientOption
715715
// network error. This can also be set through the "socketTimeoutMS" URI option (e.g. "socketTimeoutMS=1000"). The
716716
// default value is 0, meaning no timeout is used and socket operations can block indefinitely.
717717
//
718-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
719-
// Timeout option should be used in its place to control the amount of time that a single operation can run on the Client
720-
// before returning an error.
718+
// NOTE(benjirewis): SocketTimeout will be deprecated in a future release. The more general Timeout option may be used
719+
// in its place to control the amount of time that a single operation can run before returning an error. Setting
720+
// SocketTimeout and Timeout on a single client will result in undefined behavior.
721721
func (c *ClientOptions) SetSocketTimeout(d time.Duration) *ClientOptions {
722722
c.SocketTimeout = &d
723723
return c
@@ -728,8 +728,9 @@ func (c *ClientOptions) SetSocketTimeout(d time.Duration) *ClientOptions {
728728
// be honored if there is no deadline on the operation Context. Timeout can also be set through the "timeoutMS" URI option
729729
// (e.g. "timeoutMS=1000"). The default value is nil, meaning operations do not inherit a timeout from the Client.
730730
//
731-
// If any Timeout is set (even 0) on the Client, the values of other, deprecated timeout-related options will be ignored.
732-
// In particular: ClientOptions.SocketTimeout, WriteConcern.wTimeout, MaxTime on operations, and TransactionOptions.MaxCommitTime.
731+
// If any Timeout is set (even 0) on the Client, the values of MaxTime on operations, TransactionOptions.MaxCommitTime and
732+
// SessionOptions.DefaultMaxCommitTime will be ignored. Setting Timeout and ClientOptions.SocketTimeout or WriteConcern.wTimeout
733+
// will result in undefined behavior.
733734
//
734735
// NOTE(benjirewis): SetTimeout represents unstable, provisional API. The behavior of the driver when a Timeout is specified is
735736
// subject to change.

mongo/options/countoptions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ type CountOptions struct {
3434
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there is
3535
// no time limit for query execution.
3636
//
37-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
38-
// Timeout option should be used in its place to control the amount of time that the count operation can run before
39-
// returning an error. MaxTime is still usable through the deprecated setter.
37+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used in
38+
// its place to control the amount of time that a single operation can run before returning an error. MaxTime is
39+
// ignored if Timeout is set on the client.
4040
MaxTime *time.Duration
4141

4242
// The number of documents to skip before counting. The default value is 0.
@@ -74,9 +74,9 @@ func (co *CountOptions) SetLimit(i int64) *CountOptions {
7474

7575
// SetMaxTime sets the value for the MaxTime field.
7676
//
77-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
78-
// Timeout option should be used in its place to control the amount of time that the count operation can run before
79-
// returning an error.
77+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
78+
// option may be used in its place to control the amount of time that a single operation can
79+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
8080
func (co *CountOptions) SetMaxTime(d time.Duration) *CountOptions {
8181
co.MaxTime = &d
8282
return co

mongo/options/distinctoptions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ type DistinctOptions struct {
2222
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
2323
// is no time limit for query execution.
2424
//
25-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
26-
// Timeout option should be used in its place to control the amount of time that the Distinct operation can run before
27-
// returning an error. MaxTime is still usable through the deprecated setter.
25+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be
26+
// used in its place to control the amount of time that a single operation can run before returning an error.
27+
// MaxTime is ignored if Timeout is set on the client.
2828
MaxTime *time.Duration
2929
}
3030

@@ -47,9 +47,9 @@ func (do *DistinctOptions) SetComment(comment interface{}) *DistinctOptions {
4747

4848
// SetMaxTime sets the value for the MaxTime field.
4949
//
50-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
51-
// Timeout option should be used in its place to control the amount of time that the Distinct operation can run before
52-
// returning an error.
50+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
51+
// option may be used in its place to control the amount of time that a single operation can
52+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
5353
func (do *DistinctOptions) SetMaxTime(d time.Duration) *DistinctOptions {
5454
do.MaxTime = &d
5555
return do

mongo/options/estimatedcountoptions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ type EstimatedDocumentCountOptions struct {
1717
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
1818
// is no time limit for query execution.
1919
//
20-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
21-
// Timeout option should be used in its place to control the amount of time that the EstimatedDocumentCount operation
22-
// can run before returning an error. MaxTime is still usable through the deprecated setter.
20+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used
21+
// in its place to control the amount of time that a single operation can run before returning an error. MaxTime
22+
// is ignored if Timeout is set on the client.
2323
MaxTime *time.Duration
2424
}
2525

@@ -36,9 +36,9 @@ func (eco *EstimatedDocumentCountOptions) SetComment(comment interface{}) *Estim
3636

3737
// SetMaxTime sets the value for the MaxTime field.
3838
//
39-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
40-
// Timeout option should be used in its place to control the amount of time that the EstimatedDocumentCount operation
41-
// can run before returning an error.
39+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option
40+
// may be used in its place to control the amount of time that a single operation can run before
41+
// returning an error. MaxTime is ignored if Timeout is set on the client.
4242
func (eco *EstimatedDocumentCountOptions) SetMaxTime(d time.Duration) *EstimatedDocumentCountOptions {
4343
eco.MaxTime = &d
4444
return eco

mongo/options/findoptions.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ type FindOptions struct {
6060
// MaxTime is the maximum amount of time that the query can run on the server. The default value is nil, meaning that there
6161
// is no time limit for query execution.
6262
//
63-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
64-
// Timeout option should be used in its place to control the amount of time that the Find operation can run before
65-
// returning an error. MaxTime is still usable through the deprecated setter.
63+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used in its
64+
// place to control the amount of time that a single operation can run before returning an error. MaxTime is ignored if
65+
// Timeout is set on the client.
6666
MaxTime *time.Duration
6767

6868
// Min is a document specifying the inclusive lower bound for a specific index. The default value is 0, which means that
@@ -184,9 +184,9 @@ func (f *FindOptions) SetMaxAwaitTime(d time.Duration) *FindOptions {
184184

185185
// SetMaxTime specifies the max time to allow the query to run.
186186
//
187-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver.
188-
// The more general Timeout option should be used in its place to control the amount of time that the
189-
// Find operation can run before returning an error.
187+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
188+
// option may be used used in its place to control the amount of time that a single operation
189+
// can run before returning an error. MaxTime is ignored if Timeout is set on the client.
190190
func (f *FindOptions) SetMaxTime(d time.Duration) *FindOptions {
191191
f.MaxTime = &d
192192
return f
@@ -370,9 +370,9 @@ type FindOneOptions struct {
370370
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
371371
// is no time limit for query execution.
372372
//
373-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
374-
// Timeout option should be used in its place to control the amount of time that the FindOne operation can run before
375-
// returning an error. MaxTime is still usable through the deprecated setter.
373+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used
374+
// in its place to control the amount of time that a single operation can run before returning an error. MaxTime
375+
// is ignored if Timeout is set on the client.
376376
MaxTime *time.Duration
377377

378378
// A document specifying the inclusive lower bound for a specific index. The default value is 0, which means that
@@ -478,9 +478,9 @@ func (f *FindOneOptions) SetMaxAwaitTime(d time.Duration) *FindOneOptions {
478478

479479
// SetMaxTime sets the value for the MaxTime field.
480480
//
481-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
482-
// Timeout option should be used in its place to control the amount of time that the FindOne operation can run before
483-
// returning an error.
481+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
482+
// option may be used in its place to control the amount of time that a single operation can
483+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
484484
func (f *FindOneOptions) SetMaxTime(d time.Duration) *FindOneOptions {
485485
f.MaxTime = &d
486486
return f
@@ -634,9 +634,9 @@ type FindOneAndReplaceOptions struct {
634634
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
635635
// is no time limit for query execution.
636636
//
637-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
638-
// Timeout option should be used in its place to control the amount of time that the FindOneAndReplace operation can
639-
// run before returning an error. MaxTime is still usable through the deprecated setter.
637+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used
638+
// in its place to control the amount of time that a single operation can run before returning an error. MaxTime
639+
// is ignored if Timeout is set on the client.
640640
MaxTime *time.Duration
641641

642642
// A document describing which fields will be included in the document returned by the operation. The default value
@@ -696,9 +696,9 @@ func (f *FindOneAndReplaceOptions) SetComment(comment interface{}) *FindOneAndRe
696696

697697
// SetMaxTime sets the value for the MaxTime field.
698698
//
699-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
700-
// Timeout option should be used in its place to control the amount of time that the FindOneAndReplace operation can
701-
// run before returning an error.
699+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
700+
// option may be used in its place to control the amount of time that a single operation can
701+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
702702
func (f *FindOneAndReplaceOptions) SetMaxTime(d time.Duration) *FindOneAndReplaceOptions {
703703
f.MaxTime = &d
704704
return f
@@ -808,9 +808,9 @@ type FindOneAndUpdateOptions struct {
808808
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
809809
// is no time limit for query execution.
810810
//
811-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
812-
// Timeout option should be used in its place to control the amount of time that the FindOneAndUpdate operation can run
813-
// before returning an error. MaxTime is still usable through the deprecated setter.
811+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used
812+
// in its place to control the amount of time that a single operation can run before returning an error. MaxTime is
813+
// ignored if Timeout is set on the client.
814814
MaxTime *time.Duration
815815

816816
// A document describing which fields will be included in the document returned by the operation. The default value
@@ -876,9 +876,9 @@ func (f *FindOneAndUpdateOptions) SetComment(comment interface{}) *FindOneAndUpd
876876

877877
// SetMaxTime sets the value for the MaxTime field.
878878
//
879-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
880-
// Timeout option should be used in its place to control the amount of time that the FindOneAndUpdate operation can run
881-
// before returning an error.
879+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
880+
// option may be used in its place to control the amount of time that a single operation can
881+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
882882
func (f *FindOneAndUpdateOptions) SetMaxTime(d time.Duration) *FindOneAndUpdateOptions {
883883
f.MaxTime = &d
884884
return f
@@ -980,9 +980,9 @@ type FindOneAndDeleteOptions struct {
980980
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
981981
// is no time limit for query execution.
982982
//
983-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
984-
// Timeout option should be used in its place to control the amount of time that the FindOneAndDelete operation can run
985-
// before returning an error. MaxTime is still usable through the deprecated setter.
983+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used
984+
// in its place to control the amount of time that a single operation can run before returning an error. MaxTime
985+
// is ignored if Timeout is set on the client.
986986
MaxTime *time.Duration
987987

988988
// A document describing which fields will be included in the document returned by the operation. The default value
@@ -1028,9 +1028,9 @@ func (f *FindOneAndDeleteOptions) SetComment(comment interface{}) *FindOneAndDel
10281028

10291029
// SetMaxTime sets the value for the MaxTime field.
10301030
//
1031-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
1032-
// Timeout option should be used in its place to control the amount of time that the FindOneAndDelete operation can run
1033-
// before returning an error.
1031+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
1032+
// option may be used in its place to control the amount of time that a single operation can
1033+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
10341034
func (f *FindOneAndDeleteOptions) SetMaxTime(d time.Duration) *FindOneAndDeleteOptions {
10351035
f.MaxTime = &d
10361036
return f

mongo/options/gridfsoptions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ type GridFSFindOptions struct {
226226
// The maximum amount of time that the query can run on the server. The default value is nil, meaning that there
227227
// is no time limit for query execution.
228228
//
229-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver. The more general
230-
// Timeout option should be used in its place to control the amount of time that GridFS operations can run before
231-
// returning an error. MaxTime is still usable through the deprecated setter.
229+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout option may be used
230+
// in its place to control the amount of time that a single operation can run before returning an error. MaxTime
231+
// is ignored if Timeout is set on the client.
232232
MaxTime *time.Duration
233233

234234
// If true, the cursor created by the operation will not timeout after a period of inactivity. The default value
@@ -268,9 +268,9 @@ func (f *GridFSFindOptions) SetLimit(i int32) *GridFSFindOptions {
268268

269269
// SetMaxTime sets the value for the MaxTime field.
270270
//
271-
// Deprecated: This option is deprecated and will eventually be removed in version 2.0 of the driver.
272-
// The more general Timeout option should be used in its place to control the amount of time that
273-
// GridFS operations can run before returning an error.
271+
// NOTE(benjirewis): MaxTime will be deprecated in a future release. The more general Timeout
272+
// option may be used in its place to control the amount of time that a single operation can
273+
// run before returning an error. MaxTime is ignored if Timeout is set on the client.
274274
func (f *GridFSFindOptions) SetMaxTime(d time.Duration) *GridFSFindOptions {
275275
f.MaxTime = &d
276276
return f

0 commit comments

Comments
 (0)