* Release a session to the session pool * Adds the session back to the session pool if the session has not timed out yet. * This method also removes any stale sessions from the pool. * * @param session - The session to release to the pool
(session: ServerSession)
| 1137 | * @param session - The session to release to the pool |
| 1138 | */ |
| 1139 | release(session: ServerSession): void { |
| 1140 | const sessionTimeoutMinutes = this.client.topology?.logicalSessionTimeoutMinutes ?? 10; |
| 1141 | |
| 1142 | if (this.client.topology?.loadBalanced && !sessionTimeoutMinutes) { |
| 1143 | this.sessions.unshift(session); |
| 1144 | } |
| 1145 | |
| 1146 | if (!sessionTimeoutMinutes) { |
| 1147 | return; |
| 1148 | } |
| 1149 | |
| 1150 | this.sessions.prune(session => session.hasTimedOut(sessionTimeoutMinutes)); |
| 1151 | |
| 1152 | if (!session.hasTimedOut(sessionTimeoutMinutes)) { |
| 1153 | if (session.isDirty) { |
| 1154 | return; |
| 1155 | } |
| 1156 | |
| 1157 | // otherwise, readd this session to the session pool |
| 1158 | this.sessions.unshift(session); |
| 1159 | } |
| 1160 | } |
| 1161 | } |
| 1162 | |
| 1163 | /** |
no test coverage detected