Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
Loading...
Searching...
No Matches
transactions_cleanup_config.hxx
Go to the documentation of this file.
1/*
2 * Copyright 2021-Present 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#pragma once
17
19
20#include <chrono>
21#include <list>
22
24{
29{
30public:
39 {
40 cleanup_lost_attempts_ = value;
41 return *this;
42 }
49 [[nodiscard]] auto cleanup_lost_attempts() const -> bool
50 {
51 return cleanup_lost_attempts_;
52 }
53
62 {
63 cleanup_client_attempts_ = value;
64 return *this;
65 }
66
75 [[nodiscard]] auto cleanup_client_attempts() const -> bool
76 {
77 return cleanup_client_attempts_;
78 }
79
92 [[nodiscard]] auto cleanup_window() const -> std::chrono::milliseconds
93 {
94 return cleanup_window_;
95 }
96
104 template<typename T>
106 {
107 cleanup_window_ = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
108 return *this;
109 }
110
119 {
120 collections_.emplace_back(keyspace);
121 return *this;
122 }
123
125 struct built {
126 bool cleanup_lost_attempts;
127 bool cleanup_client_attempts;
128 std::chrono::milliseconds cleanup_window;
129 std::list<couchbase::transactions::transaction_keyspace> collections;
130 };
131
133 [[nodiscard]] auto build() const -> built
134 {
135 return { cleanup_lost_attempts_, cleanup_client_attempts_, cleanup_window_, collections_ };
136 }
137
138private:
139 bool cleanup_lost_attempts_{ true };
140 bool cleanup_client_attempts_{ true };
141 std::chrono::milliseconds cleanup_window_{ std::chrono::seconds(60) };
142 std::list<couchbase::transactions::transaction_keyspace> collections_{};
143};
144} // namespace couchbase::transactions
Configuration parameters for the background transaction cleanup threads.
Definition transactions_cleanup_config.hxx:29
auto add_collection(const couchbase::transactions::transaction_keyspace &keyspace) -> transactions_cleanup_config &
Add a collection to be cleaned.
Definition transactions_cleanup_config.hxx:117
auto cleanup_window() const -> std::chrono::milliseconds
Get cleanup window.
Definition transactions_cleanup_config.hxx:92
auto cleanup_client_attempts() const -> bool
Get state of client attempts cleanup loop.
Definition transactions_cleanup_config.hxx:75
auto cleanup_client_attempts(bool value) -> transactions_cleanup_config &
Set state for the client attempts cleanup loop.
Definition transactions_cleanup_config.hxx:61
auto cleanup_lost_attempts(bool value) -> transactions_cleanup_config &
Enable/disable the lost attempts cleanup loop.
Definition transactions_cleanup_config.hxx:38
auto cleanup_window(T duration) -> transactions_cleanup_config &
Set cleanup window.
Definition transactions_cleanup_config.hxx:105
auto cleanup_lost_attempts() const -> bool
Get lost attempts cleanup loop status.
Definition transactions_cleanup_config.hxx:49
Definition transactions.hxx:28
Offline, serializable representation of a bucket, scope, and collection.
Definition transaction_keyspace.hxx:25