Skip to content

Commit d0ccb56

Browse files
mbroadstdaprahamian
authored andcommitted
feat: add known, data-bearing filters to TopologyDescription
1 parent 852e14f commit d0ccb56

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/core/sdam/topology_description.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22
const ServerType = require('./server_description').ServerType;
33
const ServerDescription = require('./server_description').ServerDescription;
4-
const ReadPreference = require('../topologies/read_preference');
54
const WIRE_CONSTANTS = require('../wireprotocol/constants');
65

76
// contstants related to compatability checks
@@ -258,24 +257,17 @@ class TopologyDescription {
258257
}
259258

260259
/**
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
266261
*/
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);
269264
}
270265

271266
/**
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.
276268
*/
277-
hasWritableServer() {
278-
return this.hasReadableServer(ReadPreference.primary);
269+
get hasDataBearingServers() {
270+
return Array.from(this.servers.values()).some(sd => sd.isDataBearing);
279271
}
280272

281273
/**

0 commit comments

Comments
 (0)