-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Go Drivers
Context
The Go Driver uses contexts to set operation-level timeouts. For example, timing out an insert:
ctx, _ = context.WithTimeout(ctx, 10 * time.Second)
coll.Insert(ctx, bson.D{{"x",1}})
This works well with non-zero timeouts. However, applying the “0 means infinite” requirement at the operation-level using a context is not possible. If a user sets the timeout as zero on a context, the context time out immediately. See example here.
Definition of done
Create a context wrapper in the stable API that returns a context for the "0 means infinite" case, allowing users to specify infinite operation-level timeouts. Note that merely omitting a timeout for the context won't suffice because a non-zero client-level timeout would still be honored:
// In the mongo package
func WithInfiniteTimeout(parent context.Context) (context.Context, context.CancelFuc) {}
If this solution is deemed unacceptable by the Go Team, consider revising the CSOT specifications to make "0 means infinite" optional at the operation level and skip all tests with this criteria.