Skip to content

Commit 852e14f

Browse files
mbroadstdaprahamian
authored andcommitted
feat: add concept of data-bearing type to ServerDescription
1 parent 5c8bf32 commit 852e14f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/core/sdam/server_description.js

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ const WRITABLE_SERVER_TYPES = new Set([
1919
ServerType.Mongos
2020
]);
2121

22+
const DATA_BEARING_SERVER_TYPES = new Set([
23+
ServerType.RSPrimary,
24+
ServerType.RSSecondary,
25+
ServerType.Mongos,
26+
ServerType.Standalone
27+
]);
28+
2229
const ISMASTER_FIELDS = [
2330
'minWireVersion',
2431
'maxWireVersion',
@@ -99,6 +106,13 @@ class ServerDescription {
99106
return this.type === ServerType.RSSecondary || this.isWritable;
100107
}
101108

109+
/**
110+
* @return {Boolean} Is this server data bearing
111+
*/
112+
get isDataBearing() {
113+
return DATA_BEARING_SERVER_TYPES.has(this.type);
114+
}
115+
102116
/**
103117
* @return {Boolean} Is this server available for writes
104118
*/

0 commit comments

Comments
 (0)