15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_TRANSACTION_H 16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_TRANSACTION_H 18 #include "google/cloud/spanner/internal/transaction_impl.h" 21 #include <google/spanner/v1/transaction.pb.h> 36 Transaction MakeSingleUseTransaction(T&&);
37 template <
typename Functor>
38 VisitInvokeResult<Functor> Visit(Transaction, Functor&&);
39 Transaction MakeTransactionFromIds(std::string session_id,
40 std::string transaction_id);
83 google::spanner::v1::TransactionOptions_ReadOnly ro_opts_;
96 google::spanner::v1::TransactionOptions_ReadWrite rw_opts_;
125 google::spanner::v1::TransactionOptions_ReadOnly ro_opts_;
156 return a.impl_ == b.impl_;
165 template <
typename T>
166 friend Transaction internal::MakeSingleUseTransaction(T&&);
167 template <
typename Functor>
168 friend internal::VisitInvokeResult<Functor> internal::Visit(
Transaction,
170 friend Transaction internal::MakeTransactionFromIds(
171 std::string session_id, std::string transaction_id);
176 Transaction(std::string session_id, std::string transaction_id);
178 std::shared_ptr<internal::TransactionImpl> impl_;
188 return Transaction(std::move(opts));
198 return Transaction(std::move(opts));
209 return Transaction(txn, std::move(opts));
214 template <
typename T>
215 Transaction MakeSingleUseTransaction(T&& opts) {
217 Transaction::SingleUseOptions su_opts = std::forward<T>(opts);
218 return Transaction(std::move(su_opts));
221 template <
typename Functor>
226 VisitInvokeResult<Functor> Visit(Transaction txn, Functor&& f) {
227 return txn.impl_->Visit(std::forward<Functor>(f));
236 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_TRANSACTION_H Transaction MakeReadWriteTransaction(Transaction const &txn, Transaction::ReadWriteOptions opts={})
Create a read-write transaction configured with opts, and sharing lock priority with txn.
Options for "single-use", ReadOnly transactions, where Spanner chooses the read timestamp,...
friend bool operator!=(Transaction const &a, Transaction const &b)
Transaction MakeReadOnlyTransaction(Transaction::ReadOnlyOptions opts={})
Create a read-only transaction configured with opts.
friend bool operator==(Transaction const &a, Transaction const &b)
Contains all the Cloud Spanner C++ client types and functions.
#define SPANNER_CLIENT_NS
The representation of a Cloud Spanner transaction.
Options for ReadOnly transactions.
A representation of the Spanner TIMESTAMP type: An instant in time.
Options for ReadWrite transactions.