Couchbase C++ SDK 1.0.1 (rev. 58d46d7)
Loading...
Searching...
No Matches
transactions_config.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2021-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#pragma once
18
23
24#include <chrono>
25#include <memory>
26#include <optional>
27
29{
31struct attempt_context_testing_hooks;
32
34struct cleanup_testing_hooks;
35} // namespace couchbase::core::transactions
36
38{
43{
44public:
46
48
50
52
54
62 [[nodiscard]] auto durability_level() const -> couchbase::durability_level
63 {
64 return level_;
65 }
66
76 {
77 level_ = level;
78 return *this;
79 }
80
90 [[nodiscard]] auto timeout() const -> std::chrono::nanoseconds
91 {
92 return timeout_;
93 }
100 template<typename T>
101 auto timeout(T duration) -> transactions_config&
102 {
103 timeout_ = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
104 return *this;
105 }
106
115 {
116 metadata_collection_ = keyspace;
117 return *this;
118 }
119
120 [[nodiscard]] auto metadata_collection() const
122 {
123 return metadata_collection_;
124 }
125
131 [[nodiscard]] auto query_config() const -> const transactions_query_config&
132 {
133 return query_config_;
134 }
135
142 {
143 return query_config_;
144 }
145
153 {
154 query_config_ = config;
155 return *this;
156 }
157
163 [[nodiscard]] auto cleanup_config() const -> const transactions_cleanup_config&
164 {
165 return cleanup_config_;
166 }
167
174 {
175 return cleanup_config_;
176 }
177
185 {
186 cleanup_config_ = cleanup_config;
187 return *this;
188 }
189
191 auto test_factories(std::shared_ptr<core::transactions::attempt_context_testing_hooks> hooks,
192 std::shared_ptr<core::transactions::cleanup_testing_hooks> cleanup_hooks)
194 {
195 attempt_context_hooks_ = hooks;
196 cleanup_hooks_ = cleanup_hooks;
197 return *this;
198 }
199
201 [[nodiscard]] auto attempt_context_hooks() const
202 -> core::transactions::attempt_context_testing_hooks&
203 {
204 return *attempt_context_hooks_;
205 }
206
208 [[nodiscard]] auto cleanup_hooks() const -> core::transactions::cleanup_testing_hooks&
209 {
210 return *cleanup_hooks_;
211 }
212
214 struct built {
216 std::chrono::nanoseconds timeout;
217 std::shared_ptr<core::transactions::attempt_context_testing_hooks> attempt_context_hooks;
218 std::shared_ptr<core::transactions::cleanup_testing_hooks> cleanup_hooks;
219 std::optional<couchbase::transactions::transaction_keyspace> metadata_collection;
220 transactions_query_config::built query_config;
221 transactions_cleanup_config::built cleanup_config;
222 };
223
225 [[nodiscard]] auto build() const -> built;
226
227private:
229 std::chrono::nanoseconds timeout_{ std::chrono::seconds(15) };
230 std::shared_ptr<core::transactions::attempt_context_testing_hooks> attempt_context_hooks_;
231 std::shared_ptr<core::transactions::cleanup_testing_hooks> cleanup_hooks_;
232 std::optional<couchbase::transactions::transaction_keyspace> metadata_collection_;
233 transactions_query_config query_config_{};
234 transactions_cleanup_config cleanup_config_{};
235};
236} // namespace couchbase::transactions
Configuration parameters for the background transaction cleanup threads.
Definition transactions_cleanup_config.hxx:29
Configuration parameters for transactions.
Definition transactions_config.hxx:43
auto query_config() const -> const transactions_query_config &
Get the query config values.
Definition transactions_config.hxx:131
auto cleanup_config() const -> const transactions_cleanup_config &
Get the cleanup configuration for transactions.
Definition transactions_config.hxx:163
transactions_config(transactions_config &&c) noexcept
auto metadata_collection() const -> std::optional< couchbase::transactions::transaction_keyspace >
Definition transactions_config.hxx:120
auto metadata_collection(const couchbase::transactions::transaction_keyspace &keyspace) -> transactions_config &
Set the transaction's metadata collection.
Definition transactions_config.hxx:113
auto operator=(const transactions_config &c) -> transactions_config &
auto timeout(T duration) -> transactions_config &
Set the timeout for transactions.
Definition transactions_config.hxx:101
auto durability_level(enum couchbase::durability_level level) -> transactions_config &
Set the default durability level for all transaction operations.
Definition transactions_config.hxx:75
auto query_config(const transactions_query_config &config) -> transactions_config &
Set the query configuration for transactions.
Definition transactions_config.hxx:152
transactions_config(const transactions_config &c)
auto cleanup_config() -> transactions_cleanup_config &
Get the cleanup configuration for transactions.
Definition transactions_config.hxx:173
auto cleanup_config(const transactions_cleanup_config &cleanup_config) -> transactions_config &
Set the cleanup configuration.
Definition transactions_config.hxx:184
auto durability_level() const -> couchbase::durability_level
Get the default durability level for all transaction operations.
Definition transactions_config.hxx:62
auto query_config() -> transactions_query_config &
Get the query config values.
Definition transactions_config.hxx:141
auto timeout() const -> std::chrono::nanoseconds
Get the timeout for transactions.
Definition transactions_config.hxx:90
The transactions_query_config sets the defaults for all queries in the transactions.
Definition transactions_query_config.hxx:26
The transactions object is used to initiate a transaction.
Definition transactions.hxx:39
Definition transaction_get_result.hxx:28
Definition transactions.hxx:28
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
durability_level
Specifies enhanced durability options for the mutation.
Definition durability_level.hxx:30
@ majority
The mutation must be replicated to a majority of the Data Service nodes (that is, held in the memory ...
Offline, serializable representation of a bucket, scope, and collection.
Definition transaction_keyspace.hxx:25