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

Method endSessions

src/mongo_client.ts:802–821  ·  view source on GitHub ↗
(
      client: MongoClient,
      { description: topologyDescription }: Topology
    )

Source from the content-addressed store, hash-verified

800 }
801
802 async function endSessions(
803 client: MongoClient,
804 { description: topologyDescription }: Topology
805 ) {
806 // If we would attempt to select a server and get nothing back we short circuit
807 // to avoid the server selection timeout.
808 const selector = readPreferenceServerSelector(ReadPreference.primaryPreferred);
809 const serverDescriptions = Array.from(topologyDescription.servers.values());
810 const servers = selector(topologyDescription, serverDescriptions, new DeprioritizedServers());
811 if (servers.length !== 0) {
812 const endSessions = Array.from(client.s.sessionPool.sessions, ({ id }) => id);
813 if (endSessions.length !== 0) {
814 try {
815 await executeOperation(client, new EndSessionsOperation(endSessions));
816 } catch (error) {
817 squashError(error);
818 }
819 }
820 }
821 }
822 }
823
824 /**

Callers

nothing calls this directly

Calls 3

executeOperationFunction · 0.90
squashErrorFunction · 0.90

Tested by

no test coverage detected