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

Always use context.Background for Cursor.Close in examples

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Go Drivers

      Context

      Best practice is to use context.Background when closing a cursor to make sure the server-side resources get cleaned up, unless there is a specific reason why timing out on the client-side is more important than cleaning up cursors on the server-side. We should update our documentation to use that pattern and add a note about the tradeoff.

      Inspired by this forum post.

      Definition of done

      • Update all examples in the mongo-go-driver repo to use context.Background when calling cursor.Close.
        • Add a comment that describes why it's best to use context.Background and describes the tradeoff.
      • Create a DOCSP ticket to update all doc site examples to use context.Background when calling cursor.Close.

      Pitfalls

      What should the implementer watch out for? What are the risks?

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: