Couchbase C++ SDK 1.1.0 (rev. effbd6e)
Loading...
Searching...
No Matches
application_telemetry_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#include <string>
23
24namespace couchbase
25{
27{
28public:
29 static constexpr std::chrono::milliseconds default_ping_interval{ std::chrono::seconds{ 30 } };
30 static constexpr std::chrono::milliseconds default_ping_timeout{ std::chrono::seconds{ 2 } };
31 static constexpr std::chrono::milliseconds default_backoff_interval{ std::chrono::hours{ 1 } };
32
41 {
42 enabled_ = enable;
43 return *this;
44 }
45
53 auto ping_interval(std::chrono::milliseconds interval) -> application_telemetry_options&
54 {
55 ping_interval_ = interval;
56 return *this;
57 }
58
67 auto ping_timeout(std::chrono::milliseconds timeout) -> application_telemetry_options&
68 {
69 ping_timeout_ = timeout;
70 return *this;
71 }
72
83 auto override_endpoint(std::string endpoint) -> application_telemetry_options&
84 {
85 endpoint_ = std::move(endpoint);
86 return *this;
87 }
88
97 auto backoff_interval(std::chrono::milliseconds interval) -> application_telemetry_options&
98 {
99 backoff_interval_ = interval;
100 return *this;
101 }
102 struct built {
104 std::chrono::milliseconds ping_interval;
105 std::chrono::milliseconds ping_timeout;
106 std::chrono::milliseconds backoff_interval;
107 std::string endpoint;
108 };
109
110 [[nodiscard]] auto build() const -> built
111 {
112 return {
113 enabled_, ping_interval_, ping_timeout_, backoff_interval_, endpoint_,
114 };
115 }
116
117private:
118 bool enabled_{ true };
119 std::chrono::milliseconds ping_interval_{ default_ping_interval };
120 std::chrono::milliseconds ping_timeout_{ default_ping_timeout };
121 std::chrono::milliseconds backoff_interval_{ default_backoff_interval };
122 std::string endpoint_{};
123};
124} // namespace couchbase
Definition application_telemetry_options.hxx:27
auto ping_timeout(std::chrono::milliseconds timeout) -> application_telemetry_options &
How long the SDK should wait for ping response (pong frame) back from application service telemetry c...
Definition application_telemetry_options.hxx:67
auto build() const -> built
Definition application_telemetry_options.hxx:110
static constexpr std::chrono::milliseconds default_ping_interval
Definition application_telemetry_options.hxx:29
auto backoff_interval(std::chrono::milliseconds interval) -> application_telemetry_options &
How long should the SDK wait between connection attempts to the collector to avoid performance and st...
Definition application_telemetry_options.hxx:97
auto override_endpoint(std::string endpoint) -> application_telemetry_options &
Override the endpoint for the application service telementry.
Definition application_telemetry_options.hxx:83
static constexpr std::chrono::milliseconds default_ping_timeout
Definition application_telemetry_options.hxx:30
static constexpr std::chrono::milliseconds default_backoff_interval
Definition application_telemetry_options.hxx:31
auto ping_interval(std::chrono::milliseconds interval) -> application_telemetry_options &
How often the SDK should ping application service telemetry collector.
Definition application_telemetry_options.hxx:53
auto enable(bool enable) -> application_telemetry_options &
Whether to enable application telemetry.
Definition application_telemetry_options.hxx:40
Represents a single item from the result of scan()
Definition allow_querying_search_index_options.hxx:28
@ timeout
Definition analytics_status.hxx:34
Definition application_telemetry_options.hxx:102
std::chrono::milliseconds backoff_interval
Definition application_telemetry_options.hxx:106
std::string endpoint
Definition application_telemetry_options.hxx:107
std::chrono::milliseconds ping_interval
Definition application_telemetry_options.hxx:104
bool enabled
Definition application_telemetry_options.hxx:103
std::chrono::milliseconds ping_timeout
Definition application_telemetry_options.hxx:105