lib/mongo/cluster/sdam_flow.rb in mongo-2.14.0 vs lib/mongo/cluster/sdam_flow.rb in mongo-2.14.1
- old
+ new
@@ -176,10 +176,11 @@
end
else
raise ArgumentError, "Unknown topology #{topology.class}"
end
+ verify_invariants
commit_changes
disconnect_servers
end
# Transitions from unknown to single topology type, when a standalone
@@ -361,10 +362,13 @@
if server = cluster.add(address_str, monitor: false)
added_servers << server
end
end
end
+
+ verify_invariants
+
added_servers
end
# Removes servers from the topology which are not present in the
# given server description (which is supposed to have come from a
@@ -596,8 +600,18 @@
server_descriptions = servers_list.map do |server|
[server.address.to_s, server.description]
end
@previous_server_descriptions != server_descriptions
+ end
+
+ def verify_invariants
+ if Mongo::Lint.enabled?
+ if cluster.topology.single?
+ if cluster.servers_list.length > 1
+ raise Mongo::Error::LintError, "Trying to create a single topology with multiple servers: #{cluster.servers_list}"
+ end
+ end
+ end
end
end
end