MCPcopy
hub / github.com/mongodb/node-mongodb-native / createAndConnectServer

Function createAndConnectServer

src/sdam/topology.ts:841–856  ·  view source on GitHub ↗

* Creates new server instances and attempts to connect them * * @param topology - The topology that this server belongs to * @param serverDescription - The description for the server to initialize and connect to

(topology: Topology, serverDescription: ServerDescription)

Source from the content-addressed store, hash-verified

839 * @param serverDescription - The description for the server to initialize and connect to
840 */
841function createAndConnectServer(topology: Topology, serverDescription: ServerDescription) {
842 topology.emitAndLog(
843 Topology.SERVER_OPENING,
844 new ServerOpeningEvent(topology.s.id, serverDescription.address)
845 );
846
847 const server = new Server(topology, serverDescription, topology.s.options);
848 for (const event of SERVER_RELAY_EVENTS) {
849 server.on(event, (e: any) => topology.emit(event, e));
850 }
851
852 server.on(Server.DESCRIPTION_RECEIVED, description => topology.serverUpdateHandler(description));
853
854 server.connect();
855 return server;
856}
857
858/**
859 * @param topology - Topology to update.

Callers 2

_connectMethod · 0.85
updateServersFunction · 0.85

Calls 5

connectMethod · 0.95
emitAndLogMethod · 0.80
onMethod · 0.80
serverUpdateHandlerMethod · 0.80
emitMethod · 0.65

Tested by

no test coverage detected