File tree 1 file changed +6
-14
lines changed
1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
const ServerType = require ( './server_description' ) . ServerType ;
3
3
const ServerDescription = require ( './server_description' ) . ServerDescription ;
4
- const ReadPreference = require ( '../topologies/read_preference' ) ;
5
4
const WIRE_CONSTANTS = require ( '../wireprotocol/constants' ) ;
6
5
7
6
// contstants related to compatability checks
@@ -258,24 +257,17 @@ class TopologyDescription {
258
257
}
259
258
260
259
/**
261
- * Determines if the topology has a readable server available. See the table in the
262
- * following section for behaviour rules.
263
- *
264
- * @param {ReadPreference } [readPreference] An optional read preference for determining if a readable server is present
265
- * @return {Boolean } Whether there is a readable server in this topology
260
+ * Determines if the topology description has any known servers
266
261
*/
267
- hasReadableServer ( /* readPreference */ ) {
268
- // To be implemented when server selection is implemented
262
+ get hasKnownServers ( ) {
263
+ return Array . from ( this . servers . values ( ) ) . some ( sd => sd . type !== ServerDescription . Unknown ) ;
269
264
}
270
265
271
266
/**
272
- * Determines if the topology has a writable server available. See the table in the
273
- * following section for behaviour rules.
274
- *
275
- * @return {Boolean } Whether there is a writable server in this topology
267
+ * Determines if this topology description has a data-bearing server available.
276
268
*/
277
- hasWritableServer ( ) {
278
- return this . hasReadableServer ( ReadPreference . primary ) ;
269
+ get hasDataBearingServers ( ) {
270
+ return Array . from ( this . servers . values ( ) ) . some ( sd => sd . isDataBearing ) ;
279
271
}
280
272
281
273
/**
You can’t perform that action at this time.
0 commit comments