From 852e14fbb85cc8e6ac5522d5eaeb1e61623f505d Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Wed, 17 Jul 2019 09:05:12 -0400 Subject: [PATCH] feat: add concept of `data-bearing` type to `ServerDescription` --- lib/core/sdam/server_description.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/core/sdam/server_description.js b/lib/core/sdam/server_description.js index 45310a4063..41a5cf5b72 100644 --- a/lib/core/sdam/server_description.js +++ b/lib/core/sdam/server_description.js @@ -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', @@ -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 */