Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-3131

Add a context wrapper for the infinite case

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            preston.vasquez@mongodb.com Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: