Couchbase C++ SDK
1.5.0 (rev. 380784c)
Toggle main menu visibility
Loading...
Searching...
No Matches
get_replica_strategy.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 2026-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
20
#include <cstddef>
21
22
namespace
couchbase
23
{
31
enum class
replica_index
{
32
first
= 0,
33
second
= 1,
34
third
= 2,
35
};
36
43
struct
get_replica_strategy_from_index_options
{
50
struct
built
{
51
bool
wrap
;
52
};
53
79
auto
wrap
(
bool
value) ->
get_replica_strategy_from_index_options
&
80
{
81
wrap_ = value;
82
return
*
this
;
83
}
84
93
[[nodiscard]]
auto
build
() const ->
built
94
{
95
return
{ wrap_ };
96
}
97
98
private
:
99
bool
wrap_{
false
};
100
};
101
108
class
get_replica_strategy
109
{
110
public
:
121
[[nodiscard]]
static
auto
from_index
(
replica_index
index,
122
const
get_replica_strategy_from_index_options
& options = {})
123
->
get_replica_strategy
124
{
125
return
get_replica_strategy
{
static_cast<
std::size_t
>
(index), options.build() };
126
}
127
134
struct
built
{
135
std::size_t
replica_index
;
136
bool
wrap
;
137
};
138
147
[[nodiscard]]
auto
build
() const ->
built
148
{
149
return
built_;
150
}
151
152
private
:
153
get_replica_strategy
(std::size_t index,
154
const
get_replica_strategy_from_index_options::built
& options)
155
: built_{ index, options.wrap }
156
{
157
}
158
159
built built_;
160
};
161
}
// namespace couchbase
couchbase::get_replica_strategy
Selects the replica that get_replica() reads from.
Definition
get_replica_strategy.hxx:109
couchbase::get_replica_strategy::build
auto build() const -> built
Returns the strategy as an immutable value.
Definition
get_replica_strategy.hxx:147
couchbase::get_replica_strategy::from_index
static auto from_index(replica_index index, const get_replica_strategy_from_index_options &options={}) -> get_replica_strategy
Read from the replica at the given index.
Definition
get_replica_strategy.hxx:121
couchbase
Represents a single item from the result of scan().
Definition
allow_querying_search_index_options.hxx:28
couchbase::replica_index
replica_index
Replica to read from, where first is the first replica of the vbucket.
Definition
get_replica_strategy.hxx:31
couchbase::replica_index::first
@ first
Definition
get_replica_strategy.hxx:32
couchbase::replica_index::second
@ second
Definition
get_replica_strategy.hxx:33
couchbase::replica_index::third
@ third
Definition
get_replica_strategy.hxx:34
couchbase::get_replica_strategy::built
Immutable value object representing a consistent strategy.
Definition
get_replica_strategy.hxx:134
couchbase::get_replica_strategy::built::replica_index
std::size_t replica_index
Definition
get_replica_strategy.hxx:135
couchbase::get_replica_strategy::built::wrap
bool wrap
Definition
get_replica_strategy.hxx:136
couchbase::get_replica_strategy_from_index_options::built
Immutable value object representing consistent options.
Definition
get_replica_strategy.hxx:50
couchbase::get_replica_strategy_from_index_options::built::wrap
bool wrap
Definition
get_replica_strategy.hxx:51
couchbase::get_replica_strategy_from_index_options
Options for from_index().
Definition
get_replica_strategy.hxx:43
couchbase::get_replica_strategy_from_index_options::build
auto build() const -> built
Returns the options as an immutable value.
Definition
get_replica_strategy.hxx:93
couchbase::get_replica_strategy_from_index_options::wrap
auto wrap(bool value) -> get_replica_strategy_from_index_options &
Resolve an index that cannot be read as requested to the next one that can, instead of failing with r...
Definition
get_replica_strategy.hxx:79
couchbase
get_replica_strategy.hxx
Generated by
1.17.0