Couchbase C++ SDK
1.4.0 (rev. 59aa900)
Toggle main menu visibility
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
18
#include <
couchbase/transactions/transaction_keyspace.hxx
>
19
20
#include <chrono>
21
#include <list>
22
23
namespace
couchbase::transactions
24
{
28
class
transactions_cleanup_config
29
{
30
public
:
38
auto
cleanup_lost_attempts
(
bool
value) ->
transactions_cleanup_config
&
39
{
40
cleanup_lost_attempts_ = value;
41
return
*
this
;
42
}
43
49
[[nodiscard]]
auto
cleanup_lost_attempts
() const ->
bool
50
{
51
return
cleanup_lost_attempts_;
52
}
53
61
auto
cleanup_client_attempts
(
bool
value) ->
transactions_cleanup_config
&
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>
105
auto
cleanup_window
(T duration) ->
transactions_cleanup_config
&
106
{
107
cleanup_window_ = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
108
return
*
this
;
109
}
110
117
auto
add_collection
(
const
couchbase::transactions::transaction_keyspace
& keyspace)
118
->
transactions_cleanup_config
&
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
138
private
:
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
couchbase::transactions::transactions_cleanup_config
Configuration parameters for the background transaction cleanup threads.
Definition
transactions_cleanup_config.hxx:29
couchbase::transactions::transactions_cleanup_config::add_collection
auto add_collection(const couchbase::transactions::transaction_keyspace &keyspace) -> transactions_cleanup_config &
Add a collection to be cleaned.
Definition
transactions_cleanup_config.hxx:117
couchbase::transactions::transactions_cleanup_config::cleanup_window
auto cleanup_window() const -> std::chrono::milliseconds
Get cleanup window.
Definition
transactions_cleanup_config.hxx:92
couchbase::transactions::transactions_cleanup_config::cleanup_client_attempts
auto cleanup_client_attempts() const -> bool
Get state of client attempts cleanup loop.
Definition
transactions_cleanup_config.hxx:75
couchbase::transactions::transactions_cleanup_config::cleanup_client_attempts
auto cleanup_client_attempts(bool value) -> transactions_cleanup_config &
Set state for the client attempts cleanup loop.
Definition
transactions_cleanup_config.hxx:61
couchbase::transactions::transactions_cleanup_config::cleanup_lost_attempts
auto cleanup_lost_attempts(bool value) -> transactions_cleanup_config &
Enable/disable the lost attempts cleanup loop.
Definition
transactions_cleanup_config.hxx:38
couchbase::transactions::transactions_cleanup_config::cleanup_window
auto cleanup_window(T duration) -> transactions_cleanup_config &
Set cleanup window.
Definition
transactions_cleanup_config.hxx:105
couchbase::transactions::transactions_cleanup_config::cleanup_lost_attempts
auto cleanup_lost_attempts() const -> bool
Get lost attempts cleanup loop status.
Definition
transactions_cleanup_config.hxx:49
couchbase::transactions
Definition
transactions.hxx:43
couchbase::transactions::transaction_keyspace
Offline, serializable representation of a bucket, scope, and collection.
Definition
transaction_keyspace.hxx:25
transaction_keyspace.hxx
couchbase
transactions
transactions_cleanup_config.hxx
Generated by
1.17.0