-
Type: Task
-
Resolution: Unresolved
-
Priority: Unknown
-
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?