From 2c64c756000d48723aa97d7f04174c61c91d3583 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Tue, 1 May 2018 09:32:33 -0400 Subject: [PATCH] feat(topology-description): add helper method for server ownership --- lib/sdam/topology_description.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/sdam/topology_description.js b/lib/sdam/topology_description.js index 1f8ebcd24..8bd7473e0 100644 --- a/lib/sdam/topology_description.js +++ b/lib/sdam/topology_description.js @@ -226,6 +226,16 @@ class TopologyDescription { hasWritableServer() { return this.hasReadableServer(ReadPreference.primary); } + + /** + * Determines if the topology has a definition for the provided address + * + * @param {String} address + * @return {Boolean} Whether the topology knows about this server + */ + hasServer(address) { + return this.servers.has(address); + } } function topologyTypeForServerType(serverType) {