#include <mongocxx/v1/client_session.hpp>
A MongoDB client session.
- See also
-
- Attention
- This feature is experimental! It is not ready for use!
◆ with_transaction_cb
The callback function to invoke within a standalone transaction.
this is passed to the callback function and must be forwarded to operations within the callback function.
The callback function may be invoked multiple times as part of retry attempt behavior.
- Warning
- The callback function MUST allow any mongocxx::v1::server_error exceptions thrown by an operation within the callback function to propagate out of the callback function for correct retry attempt behavior. The callback function MUST NOT attempt to manually retry operations.
◆ transaction_state
The state of an associated transaction.
- Attention
- This feature is experimental! It is not ready for use!
| Enumerator |
|---|
| k_transaction_none | No associated transaction.
|
| k_transaction_starting | An associated transaction has started.
|
| k_transaction_in_progress | The associated transaction is in progress.
|
| k_transaction_committed | The associated transaction was committed.
|
| k_transaction_aborted | The associated transaction was aborted.
|
◆ ~client_session()
| mongocxx::v1::client_session::~client_session |
( |
| ) |
|
Destroy this object.
- Warning
- Invalidates all associated views and references.
◆ client_session() [1/2]
| mongocxx::v1::client_session::client_session |
( |
client_session && | other | ) |
|
|
noexcept |
Move constructor.
- Postconditions:
- other is in an assign-or-destroy-only state.
◆ client_session() [2/2]
| mongocxx::v1::client_session::client_session |
( |
client_session const & | | ) |
|
|
delete |
This class is not copyable.
◆ abort_transaction()
| void mongocxx::v1::client_session::abort_transaction |
( |
| ) |
|
Abort the current transaction.
- Exceptions
-
◆ advance_cluster_time()
Advance the "clusterTime" value for this session.
- Parameters
-
| v | A "clusterTime" value obtained by a prior call to cluster_time. |
◆ advance_operation_time()
Advance the "operationTime" value for this session.
- Parameters
-
◆ client()
| v1::client const & mongocxx::v1::client_session::client |
( |
| ) |
const |
Return the associated client object.
◆ cluster_time()
Return this session's current "clusterTime" value.
- Returns
- Empty when not available.
◆ commit_transaction()
| void mongocxx::v1::client_session::commit_transaction |
( |
| ) |
|
Commit the current transaction.
- Exceptions
-
◆ get_dirty()
| bool mongocxx::v1::client_session::get_dirty |
( |
| ) |
const |
Return true when the current session is dirty.
◆ get_transaction_state()
Return the current transaction state.
◆ id()
Return the current "lsid" (logical session ID).
- Returns
- Empty when one is not available.
◆ operation_time()
Return this session's current "operationTime" value.
- Returns
- Default-initialized when not available.
◆ operator=() [1/2]
Move assignment.
- Postconditions:
- other is in an assign-or-destroy-only state.
◆ operator=() [2/2]
This class is not copyable.
◆ opts()
| options mongocxx::v1::client_session::opts |
( |
| ) |
const |
Return the options used to create this client session.
◆ server_id()
| std::uint32_t mongocxx::v1::client_session::server_id |
( |
| ) |
const |
Return the ID of the current pinned server.
◆ start_transaction() [1/2]
| void mongocxx::v1::client_session::start_transaction |
( |
| ) |
|
Start a new transaction.
Default transaction options are applied to the new transaction.
- Exceptions
-
◆ start_transaction() [2/2]
Start a new transaction using opts instead of default transaction options.
- Exceptions
-
◆ with_transaction() [1/2]
◆ with_transaction() [2/2]
Start and commit a new standalone transaction using fn.
The behavior is approximately equivalent to:
while (
void start_transaction()
Start a new transaction.
options opts() const
Return the options used to create this client session.
Any user-defined exceptions thrown by fn will be caught and rethrown after the standalone transaction has been aborted.
- Warning
- fn MUST allow any mongocxx::v1::server_error exceptions thrown by an operation within fn to propagate out of fn for correct retry attempt behavior. fn MUST NOT attempt to manually retry operations.
- Note
- This operation uses an internal, non-configurable time limit of 120 seconds. The transaction may be retried until this time limit is exceeded.
- Exceptions
-
The documentation for this class was generated from the following file: