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"
19#include "google/cloud/spanner/timestamp.h"
20#include "google/cloud/spanner/version.h"
21#include "absl/types/optional.h"
22#include <google/spanner/v1/transaction.pb.h>
29namespace spanner_internal {
30GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
31struct TransactionInternals;
32GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
36GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
61
62
78 google::spanner::v1::TransactionOptions_ReadOnly ro_opts_;
82
83
94 google::spanner::v1::TransactionOptions_ReadWrite rw_opts_;
95 absl::optional<std::string> tag_;
99
100
101
102
103
104
105
106
107
124 google::spanner::v1::TransactionOptions_ReadOnly ro_opts_;
130
131
132
133
134
155 return a.impl_ == b.impl_;
164 friend struct spanner_internal::TransactionInternals;
165 struct SingleUseCommitTag {};
172 Transaction(std::string session_id, std::string transaction_id,
173 bool route_to_leader, std::string transaction_tag);
175 std::shared_ptr<spanner_internal::TransactionImpl> impl_;
179
180
181
182
189
190
191
192
199
200
201
202
203
209GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
212namespace spanner_internal {
213GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
215struct TransactionInternals {
216 template <
typename T>
229 template <
typename Functor>
236 return txn.impl_->Visit(std::forward<Functor>(f));
240 std::string session_id, std::string transaction_id,
bool route_to_leader,
241 std::string transaction_tag);
246 return TransactionInternals::MakeSingleUseTransaction(std::forward<T>(opts));
251 return TransactionInternals::MakeSingleUseCommitTransaction(std::move(opts));
254template <
typename Functor>
260 return TransactionInternals::Visit(std::move(txn), std::forward<Functor>(f));
264 std::string session_id, std::string transaction_id,
bool route_to_leader,
265 std::string transaction_tag) {
266 return TransactionInternals::MakeTransactionFromIds(
267 std::move(session_id), std::move(transaction_id), route_to_leader,
268 std::move(transaction_tag));
271GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
A representation of the Spanner TIMESTAMP type: An instant in time.
Definition: timestamp.h:54
Options for ReadOnly transactions.
Definition: transaction.h:63
ReadOnlyOptions(Timestamp read_timestamp)
ReadOnlyOptions(std::chrono::nanoseconds exact_staleness)
Options for ReadWrite transactions.
Definition: transaction.h:84
ReadWriteOptions & WithTag(absl::optional< std::string > tag)
Options for "single-use", ReadOnly transactions, where Spanner chooses the read timestamp,...
Definition: transaction.h:108
SingleUseOptions(std::chrono::nanoseconds max_staleness)
SingleUseOptions(Timestamp min_read_timestamp)
SingleUseOptions(ReadOnlyOptions opts)
The representation of a Cloud Spanner transaction.
Definition: transaction.h:58
Transaction(Transaction &&)=default
Transaction & operator=(Transaction const &)=default
Transaction & operator=(Transaction &&)=default
friend bool operator==(Transaction const &a, Transaction const &b)
Definition: transaction.h:154
Transaction(Transaction const &)=default
Transaction(ReadWriteOptions opts)
Transaction(Transaction const &txn, ReadWriteOptions opts)
Transaction(ReadOnlyOptions opts)
friend bool operator!=(Transaction const &a, Transaction const &b)
Definition: transaction.h:157
Contains all the Cloud Spanner C++ client types and functions.
Definition: backoff_policy.h:23
Transaction MakeReadWriteTransaction(Transaction::ReadWriteOptions opts={})
Create a read-write transaction configured with opts.
Definition: transaction.h:193
Transaction MakeReadWriteTransaction(Transaction const &txn, Transaction::ReadWriteOptions opts={})
Create a read-write transaction configured with opts, and sharing lock priority with txn.
Definition: transaction.h:204
Transaction MakeReadOnlyTransaction(Transaction::ReadOnlyOptions opts={})
Create a read-only transaction configured with opts.
Definition: transaction.h:183