Skip to content

Commit dbf6945

Browse files
authored
GODRIVER-2031 Document that Cursor isn't goroutine safe (#696)
1 parent 5199a0b commit dbf6945

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mongo/change_stream.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ var (
6161
)
6262

6363
// ChangeStream is used to iterate over a stream of events. Each event can be decoded into a Go type via the Decode
64-
// method or accessed as raw BSON via the Current field. For more information about change streams, see
64+
// method or accessed as raw BSON via the Current field. This type is not goroutine safe and must not be used
65+
// concurrently by multiple goroutines. For more information about change streams, see
6566
// https://docs.mongodb.com/manual/changeStreams/.
6667
type ChangeStream struct {
6768
// Current is the BSON bytes of the current event. This property is only valid until the next call to Next or

mongo/cursor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import (
2121
)
2222

2323
// Cursor is used to iterate over a stream of documents. Each document can be decoded into a Go type via the Decode
24-
// method or accessed as raw BSON via the Current field.
24+
// method or accessed as raw BSON via the Current field. This type is not goroutine safe and must not be used
25+
// concurrently by multiple goroutines.
2526
type Cursor struct {
2627
// Current contains the BSON bytes of the current change document. This property is only valid until the next call
2728
// to Next or TryNext. If continued access is required, a copy must be made.

0 commit comments

Comments
 (0)