Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
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
22
23#include <chrono>
24#include <optional>
25
26namespace couchbase
27{
28class collection;
29
30namespace transactions
31{
37{
38public:
40
50
58 [[nodiscard]] auto durability_level() const -> std::optional<couchbase::durability_level>;
59
69
77 [[nodiscard]] auto scan_consistency() const -> std::optional<query_scan_consistency>;
78
86 template<typename T>
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
112
121 {
122 metadata_collection_.emplace(keyspace);
123 return *this;
124 }
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)
137 [[nodiscard]] auto apply(const transactions_config::built& conf) const
138 -> transactions_config::built;
139
140private:
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
The collection provides access to all collection APIs.
Definition collection.hxx:70
The transaction_options can be passed in to override some elements of the global transactions_config.
Definition transaction_options.hxx:37
auto durability_level(durability_level level) -> transaction_options &
Set durability for this transaction.
auto timeout() -> std::optional< std::chrono::nanoseconds >
Get the timeout, if set.
auto durability_level() const -> std::optional< couchbase::durability_level >
Get the durability if it has been set.
auto metadata_collection(const couchbase::transactions::transaction_keyspace &keyspace) -> transaction_options &
Set metadata collection to use for this transaction.
Definition transaction_options.hxx:119
auto metadata_collection(const couchbase::collection &coll) -> transaction_options &
Set the metadata collection to use for this transaction.
auto metadata_collection() const -> std::optional< transaction_keyspace >
Get the metadata collection, if set.
auto scan_consistency() const -> std::optional< query_scan_consistency >
Get the scan_consistency if it has been set.
Configuration parameters for transactions.
Definition transactions_config.hxx:43
The transactions object is used to initiate a transaction.
Definition transactions.hxx:39
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
query_scan_consistency
Definition query_scan_consistency.hxx:22
durability_level
Specifies enhanced durability options for the mutation.
Definition durability_level.hxx:30
Offline, serializable representation of a bucket, scope, and collection.
Definition transaction_keyspace.hxx:25