Method: Mongo::Session#end_session
- Defined in:
- lib/mongo/session.rb
#end_session ⇒ nil
End this session.
If there is an in-progress transaction on this session, the transaction is aborted. The server session associated with this session is returned to the server session pool. Finally, this session is marked ended and is no longer usable.
If this session is already ended, this method does nothing.
Note that this method does not directly issue an endSessions command to this server, contrary to what its name might suggest.
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/mongo/session.rb', line 377 def end_session if !ended? && @client if within_states?(TRANSACTION_IN_PROGRESS_STATE) begin abort_transaction rescue Mongo::Error, Error::AuthError end end if @server_session @client.cluster.session_pool.checkin(@server_session) end end ensure @server_session = nil @ended = true end |