(
client: MongoClient,
{ description: topologyDescription }: Topology
)
| 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 | /** |
nothing calls this directly
no test coverage detected