Skip to content

Commit f9bd199

Browse files
committed
Use description package and share selectors
Use description.WriteSelector for write selectors. Use the Database's read and write selectors when creating a Collection. GODRIVER-331 GODRIVER-330 Change-Id: I8b5ef75f265840f34a2c7bdedc9636eaac571e94
1 parent ba3ea21 commit f9bd199

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

core/topology/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const minHeartbeatInterval = 500 * time.Millisecond
2323
var ErrServerClosed = errors.New("server is closed")
2424

2525
// SelectedServer represents a specific server that was selected during server selection.
26-
// It contains the kind of the typology it was selected from and the read preference that
27-
// was given during server selection.
26+
// It contains the kind of the typology it was selected from.
2827
type SelectedServer struct {
2928
*Server
3029

mongo/collection.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,10 @@ func newCollection(db *Database, name string) *Collection {
4141
readPreference: db.readPreference,
4242
readConcern: db.readConcern,
4343
writeConcern: db.writeConcern,
44+
readSelector: db.readSelector,
45+
writeSelector: db.writeSelector,
4446
}
4547

46-
coll.readSelector = description.CompositeSelector([]description.ServerSelector{
47-
description.ReadPrefSelector(coll.readPreference),
48-
description.LatencySelector(db.client.localThreshold),
49-
})
50-
51-
coll.writeSelector = description.ReadPrefSelector(readpref.Primary())
52-
5348
return coll
5449
}
5550

mongo/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func newDatabase(client *Client, name string) *Database {
4343
description.LatencySelector(db.client.localThreshold),
4444
})
4545

46-
db.writeSelector = description.ReadPrefSelector(readpref.Primary())
46+
db.writeSelector = description.WriteSelector()
4747

4848
return db
4949
}

0 commit comments

Comments
 (0)