Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
common_durability_options.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 2020-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
18#pragma once
19
24
25#include <chrono>
26#include <optional>
27#include <type_traits>
28
29namespace couchbase
30{
37template<typename derived_class>
38class common_durability_options : public common_options<derived_class>
39{
40public:
52
67 auto durability(durability_level level) -> derived_class&
68 {
69 replicate_to_ = replicate_to::none;
70 persist_to_ = persist_to::none;
71 durability_level_ = level;
73 }
74
86 auto durability(persist_to persist_to_nodes, replicate_to replicate_to_nodes) -> derived_class&
87 {
88 durability_level_ = durability_level::none;
89 replicate_to_ = replicate_to_nodes;
90 persist_to_ = persist_to_nodes;
92 }
93
94protected:
100 [[nodiscard]] auto build_common_durability_options() const -> built
101 {
103 durability_level_,
104 persist_to_,
105 replicate_to_ };
106 }
107
108private:
109 durability_level durability_level_{ durability_level::none };
110 persist_to persist_to_{ persist_to::none };
111 replicate_to replicate_to_{ replicate_to::none };
112};
113
114} // namespace couchbase
Common options that used by most operations.
Definition common_durability_options.hxx:39
auto durability(persist_to persist_to_nodes, replicate_to replicate_to_nodes) -> derived_class &
Allows to customize the poll-based durability requirements for this operation.
Definition common_durability_options.hxx:86
auto durability(durability_level level) -> derived_class &
Allows to customize the enhanced durability requirements for this operation.
Definition common_durability_options.hxx:67
auto build_common_durability_options() const -> built
Definition common_durability_options.hxx:100
Common options that used by most operations.
Definition common_options.hxx:37
auto self() -> derived_class &
Allows to return the right options builder instance for child implementations.
Definition common_options.hxx:102
auto build_common_options() const -> built
Definition common_options.hxx:89
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
persist_to
Definition persist_to.hxx:22
@ none
Do not apply any persistence requirements.
durability_level
Specifies enhanced durability options for the mutation.
Definition durability_level.hxx:30
@ none
No enhanced durability required for the mutation.
replicate_to
Definition replicate_to.hxx:22
@ none
Do not apply any replication requirements.
Immutable value object representing consistent options.
Definition common_durability_options.hxx:47
const couchbase::persist_to persist_to
Definition common_durability_options.hxx:49
const couchbase::replicate_to replicate_to
Definition common_durability_options.hxx:50
const couchbase::durability_level durability_level
Definition common_durability_options.hxx:48