Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
endpoint_diagnostics.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
21
22#include <chrono>
23#include <optional>
24#include <string>
25#include <utility>
26
27namespace couchbase
28{
29enum class endpoint_state {
37
45
53
61};
62
64{
65public:
67
73 std::string id,
74 std::optional<std::chrono::microseconds> last_activity,
75 std::string local,
76 std::string remote,
77 std::optional<std::string> endpoint_namespace,
79 std::optional<std::string> details)
80 : type_{ type }
81 , id_{ std::move(id) }
82 , last_activity_{ last_activity }
83 , local_{ std::move(local) }
84 , remote_{ std::move(remote) }
85 , namespace_{ std::move(endpoint_namespace) }
86 , state_{ state }
87 , details_{ std::move(details) }
88 {
89 }
90
99 [[nodiscard]] auto type() const -> service_type
100 {
101 return type_;
102 }
103
113 [[nodiscard]] auto id() const -> std::string
114 {
115 return id_;
116 }
117
126 [[nodiscard]] auto last_activity() const -> std::optional<std::chrono::microseconds>
127 {
128 return last_activity_;
129 }
130
139 [[nodiscard]] auto local() const -> std::string
140 {
141 return local_;
142 }
143
152 [[nodiscard]] auto remote() const -> std::string
153 {
154 return remote_;
155 }
156
165 [[nodiscard]] auto endpoint_namespace() const -> std::optional<std::string>
166 {
167 return namespace_;
168 }
169
178 [[nodiscard]] auto state() const -> endpoint_state
179 {
180 return state_;
181 }
182
191 [[nodiscard]] auto details() const -> std::optional<std::string>
192 {
193 return details_;
194 }
195
196private:
197 service_type type_{};
198 std::string id_{};
199 std::optional<std::chrono::microseconds> last_activity_{};
200 std::string local_{};
201 std::string remote_{};
202 std::optional<std::string> namespace_{};
203 endpoint_state state_{};
204 std::optional<std::string> details_{};
205};
206} // namespace couchbase
Definition endpoint_diagnostics.hxx:64
auto state() const -> endpoint_state
Returns the current state of the endpoint.
Definition endpoint_diagnostics.hxx:178
auto local() const -> std::string
Returns the local socket address for this endpoint.
Definition endpoint_diagnostics.hxx:139
auto endpoint_namespace() const -> std::optional< std::string >
Returns the namespace of this endpoint (likely the bucket name if present).
Definition endpoint_diagnostics.hxx:165
auto details() const -> std::optional< std::string >
Returns any additional details about the endpoint, if available.
Definition endpoint_diagnostics.hxx:191
endpoint_diagnostics(service_type type, std::string id, std::optional< std::chrono::microseconds > last_activity, std::string local, std::string remote, std::optional< std::string > endpoint_namespace, endpoint_state state, std::optional< std::string > details)
Definition endpoint_diagnostics.hxx:72
auto remote() const -> std::string
Returns the remote socket address for this endpoint.
Definition endpoint_diagnostics.hxx:152
auto id() const -> std::string
Returns the ID for this endpoint.
Definition endpoint_diagnostics.hxx:113
auto last_activity() const -> std::optional< std::chrono::microseconds >
Returns the time since the last activity, if there has been one.
Definition endpoint_diagnostics.hxx:126
auto type() const -> service_type
Returns the service type for this endpoint.
Definition endpoint_diagnostics.hxx:99
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
endpoint_state
Definition endpoint_diagnostics.hxx:29
@ connected
The endpoint is connected and ready.
@ disconnecting
The endpoint is currently disconnecting.
@ disconnected
The endpoint is disconnected (not reachable) and not trying to connect.
@ connecting
The endpoint is disconnected but trying to connect right now.