Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
endpoint_ping_report.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 2023-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 <cstdint>
22#include <optional>
23#include <string>
24
26
27namespace couchbase
28{
29enum class ping_state {
36 ok,
37
44 timeout,
45
52 error,
53};
54
56{
57public:
63
69 std::string id,
70 std::string local,
71 std::string remote,
73 std::optional<std::string> error,
74 std::optional<std::string> endpoint_namespace,
75 std::chrono::microseconds latency)
76 : type_{ type }
77 , id_{ std::move(id) }
78 , local_{ std::move(local) }
79 , remote_{ std::move(remote) }
80 , state_{ state }
81 , error_{ std::move(error) }
82 , namespace_{ std::move(endpoint_namespace) }
83 , latency_{ latency }
84 {
85 }
86
95 [[nodiscard]] auto type() const -> service_type
96 {
97 return type_;
98 }
99
108 [[nodiscard]] auto id() const -> std::string
109 {
110 return id_;
111 }
112
121 [[nodiscard]] auto local() const -> std::string
122 {
123 return local_;
124 }
125
134 [[nodiscard]] auto remote() const -> std::string
135 {
136 return remote_;
137 }
138
147 [[nodiscard]] auto state() const -> ping_state
148 {
149 return state_;
150 }
151
160 [[nodiscard]] auto error() const -> std::optional<std::string>
161 {
162 return error_;
163 }
164
173 [[nodiscard]] auto endpoint_namespace() const -> std::optional<std::string>
174 {
175 return namespace_;
176 }
177
186 [[nodiscard]] auto latency() const -> std::chrono::microseconds
187 {
188 return latency_;
189 }
190
191private:
192 service_type type_{};
193 std::string id_;
194 std::string local_;
195 std::string remote_;
196 ping_state state_{};
197 std::optional<std::string> error_{};
198 std::optional<std::string> namespace_{};
199 std::chrono::microseconds latency_{};
200};
201
202} // namespace couchbase
Definition endpoint_ping_report.hxx:56
auto local() const -> std::string
Returns the local socket address for this endpoint.
Definition endpoint_ping_report.hxx:121
auto endpoint_namespace() const -> std::optional< std::string >
Returns the namespace of this endpoint (likely the bucket name if present).
Definition endpoint_ping_report.hxx:173
endpoint_ping_report(service_type type, std::string id, std::string local, std::string remote, ping_state state, std::optional< std::string > error, std::optional< std::string > endpoint_namespace, std::chrono::microseconds latency)
Definition endpoint_ping_report.hxx:68
auto remote() const -> std::string
Returns the remote socket address for this endpoint.
Definition endpoint_ping_report.hxx:134
auto error() const -> std::optional< std::string >
Returns the reason this ping did not succeed, if applicable.
Definition endpoint_ping_report.hxx:160
auto id() const -> std::string
Returns the ID for this endpoint.
Definition endpoint_ping_report.hxx:108
auto state() const -> ping_state
Returns the state of this ping when assembling the report.
Definition endpoint_ping_report.hxx:147
auto latency() const -> std::chrono::microseconds
Returns the latency of this ping.
Definition endpoint_ping_report.hxx:186
auto type() const -> service_type
Returns the service type for this endpoint.
Definition endpoint_ping_report.hxx:95
Definition error.hxx:30
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
service_type
Definition service_type.hxx:22
ping_state
Definition endpoint_ping_report.hxx:29
@ ok
Indicates that the ping operation was successful.
@ error
Indicates that the ping operation failed.