Skip to content

Commit

Permalink
feat: add concept of data-bearing type to ServerDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst authored and daprahamian committed Aug 13, 2019
1 parent 5c8bf32 commit 852e14f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/core/sdam/server_description.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const WRITABLE_SERVER_TYPES = new Set([
ServerType.Mongos
]);

const DATA_BEARING_SERVER_TYPES = new Set([
ServerType.RSPrimary,
ServerType.RSSecondary,
ServerType.Mongos,
ServerType.Standalone
]);

const ISMASTER_FIELDS = [
'minWireVersion',
'maxWireVersion',
Expand Down Expand Up @@ -99,6 +106,13 @@ class ServerDescription {
return this.type === ServerType.RSSecondary || this.isWritable;
}

/**
* @return {Boolean} Is this server data bearing
*/
get isDataBearing() {
return DATA_BEARING_SERVER_TYPES.has(this.type);
}

/**
* @return {Boolean} Is this server available for writes
*/
Expand Down

0 comments on commit 852e14f

Please sign in to comment.