Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
Loading...
Searching...
No Matches
timeout_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
20#include <chrono>
21#include <cstddef>
22
23namespace couchbase
24{
26{
27public:
28 static constexpr std::chrono::milliseconds default_analytics_timeout{ std::chrono::seconds{
29 75 } };
30 static constexpr std::chrono::milliseconds default_connect_timeout{ std::chrono::seconds{ 10 } };
31 static constexpr std::chrono::milliseconds default_eventing_timeout{ std::chrono::seconds{ 75 } };
32 static constexpr std::chrono::milliseconds default_key_value_durable_timeout{
33 std::chrono::seconds{ 10 }
34 };
35 static constexpr std::chrono::milliseconds default_key_value_timeout{ 2'500 };
36 static constexpr std::chrono::milliseconds default_management_timeout{ std::chrono::seconds{
37 75 } };
38 static constexpr std::chrono::milliseconds default_query_timeout{ std::chrono::seconds{ 75 } };
39 static constexpr std::chrono::milliseconds default_search_timeout{ std::chrono::seconds{ 75 } };
40 static constexpr std::chrono::milliseconds default_view_timeout{ std::chrono::seconds{ 75 } };
41 static constexpr std::chrono::milliseconds default_bootstrap_timeout{ std::chrono::seconds{
42 10 } };
43 static constexpr std::chrono::milliseconds default_resolve_timeout{ std::chrono::seconds{ 2 } };
44
45 auto analytics_timeout(std::chrono::milliseconds timeout) -> timeout_options&
46 {
47 analytics_timeout_ = timeout;
48 return *this;
49 }
50
51 auto connect_timeout(std::chrono::milliseconds timeout) -> timeout_options&
52 {
53 connect_timeout_ = timeout;
54 return *this;
55 }
56
57 auto eventing_timeout(std::chrono::milliseconds timeout) -> timeout_options&
58 {
59 eventing_timeout_ = timeout;
60 return *this;
61 }
62
63 auto key_value_durable_timeout(std::chrono::milliseconds timeout) -> timeout_options&
64 {
65 key_value_durable_timeout_ = timeout;
66 return *this;
67 }
68
69 auto key_value_timeout(std::chrono::milliseconds timeout) -> timeout_options&
70 {
71 key_value_timeout_ = timeout;
72 return *this;
73 }
74
75 auto management_timeout(std::chrono::milliseconds timeout) -> timeout_options&
76 {
77 management_timeout_ = timeout;
78 return *this;
79 }
80
81 auto query_timeout(std::chrono::milliseconds timeout) -> timeout_options&
82 {
83 query_timeout_ = timeout;
84 return *this;
85 }
86
87 auto search_timeout(std::chrono::milliseconds timeout) -> timeout_options&
88 {
89 search_timeout_ = timeout;
90 return *this;
91 }
92
93 auto view_timeout(std::chrono::milliseconds timeout) -> timeout_options&
94 {
95 view_timeout_ = timeout;
96 return *this;
97 }
98
99 auto bootstrap_timeout(std::chrono::milliseconds timeout) -> timeout_options&
100 {
101 bootstrap_timeout_ = timeout;
102 return *this;
103 }
104
105 auto resolve_timeout(std::chrono::milliseconds timeout) -> timeout_options&
106 {
107 resolve_timeout_ = timeout;
108 return *this;
109 }
110
111 struct built {
112 std::chrono::milliseconds analytics_timeout;
113 std::chrono::milliseconds connect_timeout;
114 std::chrono::milliseconds eventing_timeout;
115 std::chrono::milliseconds key_value_durable_timeout;
116 std::chrono::milliseconds key_value_timeout;
117 std::chrono::milliseconds management_timeout;
118 std::chrono::milliseconds query_timeout;
119 std::chrono::milliseconds search_timeout;
120 std::chrono::milliseconds view_timeout;
121 std::chrono::milliseconds bootstrap_timeout;
122 std::chrono::milliseconds resolve_timeout;
123 };
124
125 [[nodiscard]] auto build() const -> built
126 {
127 return {
128 analytics_timeout_, connect_timeout_, eventing_timeout_, key_value_durable_timeout_,
129 key_value_timeout_, management_timeout_, query_timeout_, search_timeout_,
130 view_timeout_, bootstrap_timeout_, resolve_timeout_,
131 };
132 }
133
134private:
135 std::chrono::milliseconds analytics_timeout_{ default_analytics_timeout };
136 std::chrono::milliseconds connect_timeout_{ default_connect_timeout };
137 std::chrono::milliseconds eventing_timeout_{ default_eventing_timeout };
138 std::chrono::milliseconds key_value_durable_timeout_{ default_key_value_durable_timeout };
139 std::chrono::milliseconds key_value_timeout_{ default_key_value_timeout };
140 std::chrono::milliseconds management_timeout_{ default_management_timeout };
141 std::chrono::milliseconds query_timeout_{ default_query_timeout };
142 std::chrono::milliseconds search_timeout_{ default_search_timeout };
143 std::chrono::milliseconds view_timeout_{ default_view_timeout };
144 std::chrono::milliseconds bootstrap_timeout_{ default_bootstrap_timeout };
145 std::chrono::milliseconds resolve_timeout_{ default_resolve_timeout };
146};
147} // namespace couchbase
Definition timeout_options.hxx:26
static constexpr std::chrono::milliseconds default_resolve_timeout
Definition timeout_options.hxx:43
static constexpr std::chrono::milliseconds default_management_timeout
Definition timeout_options.hxx:36
static constexpr std::chrono::milliseconds default_query_timeout
Definition timeout_options.hxx:38
static constexpr std::chrono::milliseconds default_analytics_timeout
Definition timeout_options.hxx:28
auto query_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:81
auto key_value_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:69
auto key_value_durable_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:63
auto bootstrap_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:99
static constexpr std::chrono::milliseconds default_eventing_timeout
Definition timeout_options.hxx:31
static constexpr std::chrono::milliseconds default_bootstrap_timeout
Definition timeout_options.hxx:41
auto resolve_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:105
auto build() const -> built
Definition timeout_options.hxx:125
static constexpr std::chrono::milliseconds default_search_timeout
Definition timeout_options.hxx:39
auto eventing_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:57
auto analytics_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:45
static constexpr std::chrono::milliseconds default_key_value_durable_timeout
Definition timeout_options.hxx:32
auto search_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:87
static constexpr std::chrono::milliseconds default_view_timeout
Definition timeout_options.hxx:40
auto view_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:93
static constexpr std::chrono::milliseconds default_key_value_timeout
Definition timeout_options.hxx:35
static constexpr std::chrono::milliseconds default_connect_timeout
Definition timeout_options.hxx:30
auto management_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:75
auto connect_timeout(std::chrono::milliseconds timeout) -> timeout_options &
Definition timeout_options.hxx:51
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
Definition timeout_options.hxx:111
std::chrono::milliseconds search_timeout
Definition timeout_options.hxx:119
std::chrono::milliseconds view_timeout
Definition timeout_options.hxx:120
std::chrono::milliseconds connect_timeout
Definition timeout_options.hxx:113
std::chrono::milliseconds eventing_timeout
Definition timeout_options.hxx:114
std::chrono::milliseconds query_timeout
Definition timeout_options.hxx:118
std::chrono::milliseconds bootstrap_timeout
Definition timeout_options.hxx:121
std::chrono::milliseconds resolve_timeout
Definition timeout_options.hxx:122
std::chrono::milliseconds key_value_durable_timeout
Definition timeout_options.hxx:115
std::chrono::milliseconds key_value_timeout
Definition timeout_options.hxx:116
std::chrono::milliseconds management_timeout
Definition timeout_options.hxx:117
std::chrono::milliseconds analytics_timeout
Definition timeout_options.hxx:112