Couchbase C++ SDK
1.4.0 (rev. 59aa900)
Toggle main menu visibility
Loading...
Searching...
No Matches
transaction_options.hxx
Go to the documentation of this file.
1
/*
2
* Copyright 2022 Couchbase, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <
couchbase/durability_level.hxx
>
20
#include <
couchbase/query_scan_consistency.hxx
>
21
#include <
couchbase/transactions/transactions_config.hxx
>
22
23
#include <chrono>
24
#include <optional>
25
26
namespace
couchbase
27
{
28
class
collection
;
29
30
namespace
transactions
31
{
36
class
transaction_options
37
{
38
public
:
39
transaction_options
() =
default
;
40
49
auto
durability_level
(
durability_level
level) ->
transaction_options
&;
50
58
[[nodiscard]]
auto
durability_level
() const -> std::optional<
couchbase
::
durability_level
>;
59
68
auto
scan_consistency
(
query_scan_consistency
scan_consistency
) ->
transaction_options
&;
69
77
[[nodiscard]] auto
scan_consistency
() const -> std::optional<
query_scan_consistency
>;
78
86
template<typename T>
87
auto
timeout
(T
timeout
) ->
transaction_options
&
88
{
89
timeout_ = std::chrono::duration_cast<std::chrono::nanoseconds>(
timeout
);
90
return
*
this
;
91
}
92
98
auto
timeout
() -> std::optional<std::chrono::nanoseconds>;
99
111
auto
metadata_collection
(
const
couchbase::collection
& coll) ->
transaction_options
&;
112
119
auto
metadata_collection
(
const
couchbase::transactions::transaction_keyspace
& keyspace)
120
->
transaction_options
&
121
{
122
metadata_collection_.emplace(keyspace);
123
return
*
this
;
124
}
125
130
[[nodiscard]]
auto
metadata_collection
() const -> std::optional<
transaction_keyspace
>;
131
133
auto test_factories(std::shared_ptr<
core
::
transactions
::attempt_context_testing_hooks> hooks,
134
std::shared_ptr<
core
::
transactions
::cleanup_testing_hooks> cleanup_hooks)
135
->
transaction_options
&;
137
[[nodiscard]] auto apply(const
transactions_config
::built& conf) const
138
->
transactions_config
::built;
139
140
private:
141
std::optional<
couchbase
::
durability_level
> durability_;
142
std::optional<
couchbase
::
query_scan_consistency
> scan_consistency_;
143
std::optional<std::chrono::nanoseconds> timeout_;
144
std::optional<
transaction_keyspace
> metadata_collection_;
145
std::shared_ptr<
core
::
transactions
::attempt_context_testing_hooks> attempt_context_hooks_;
146
std::shared_ptr<
core
::
transactions
::cleanup_testing_hooks> cleanup_hooks_;
147
};
148
}
// namespace transactions
149
}
// namespace couchbase
couchbase::collection
The collection provides access to all collection APIs.
Definition
collection.hxx:76
couchbase::transactions::transaction_options::timeout
auto timeout(T timeout) -> transaction_options &
Set the timeout for this transaction.
Definition
transaction_options.hxx:87
couchbase::transactions::transaction_options::durability_level
auto durability_level(durability_level level) -> transaction_options &
Set durability for this transaction.
couchbase::transactions::transaction_options::timeout
auto timeout() -> std::optional< std::chrono::nanoseconds >
Get the timeout, if set.
couchbase::transactions::transaction_options::durability_level
auto durability_level() const -> std::optional< couchbase::durability_level >
Get the durability if it has been set.
couchbase::transactions::transaction_options::metadata_collection
auto metadata_collection(const couchbase::transactions::transaction_keyspace &keyspace) -> transaction_options &
Set metadata collection to use for this transaction.
Definition
transaction_options.hxx:119
couchbase::transactions::transaction_options::metadata_collection
auto metadata_collection(const couchbase::collection &coll) -> transaction_options &
Set the metadata collection to use for this transaction.
couchbase::transactions::transaction_options::transaction_options
transaction_options()=default
couchbase::transactions::transaction_options::metadata_collection
auto metadata_collection() const -> std::optional< transaction_keyspace >
Get the metadata collection, if set.
couchbase::transactions::transaction_options::scan_consistency
auto scan_consistency(query_scan_consistency scan_consistency) -> transaction_options &
Set the query_scan_consistency for this transaction.
couchbase::transactions::transactions_config
Configuration parameters for transactions.
Definition
transactions_config.hxx:43
couchbase::transactions::transactions
The transactions object is used to initiate a transaction.
Definition
transactions.hxx:52
durability_level.hxx
couchbase::core
Definition
expiry.hxx:24
couchbase::transactions
Definition
transactions.hxx:43
couchbase
Represents a single item from the result of scan().
Definition
allow_querying_search_index_options.hxx:28
couchbase::query_scan_consistency
query_scan_consistency
Definition
query_scan_consistency.hxx:22
query_scan_consistency.hxx
couchbase::transactions::transaction_keyspace
Offline, serializable representation of a bucket, scope, and collection.
Definition
transaction_keyspace.hxx:25
transactions_config.hxx
couchbase
transactions
transaction_options.hxx
Generated by
1.17.0