MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
apm.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/options/apm-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/apm.hpp> // IWYU pragma: export
22
23#include <functional>
24#include <utility>
25
38
40
41namespace mongocxx {
42namespace v_noabi {
43namespace options {
44
52class apm {
53 public:
57 apm() = default;
58
62 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() apm(v1::apm other);
63
67 explicit operator v1::apm() const {
68 v1::apm ret;
69
70 ret.on_command_started(_command_started);
71 ret.on_command_failed(_command_failed);
72 ret.on_command_succeeded(_command_succeeded);
73 ret.on_server_closed(_server_closed);
74 ret.on_server_description_changed(_server_changed);
75 ret.on_server_opening(_server_opening);
76 ret.on_topology_closed(_topology_closed);
77 ret.on_topology_description_changed(_topology_changed);
78 ret.on_topology_opening(_topology_opening);
79 ret.on_server_heartbeat_started(_heartbeat_started);
80 ret.on_server_heartbeat_failed(_heartbeat_failed);
81 ret.on_server_heartbeat_succeeded(_heartbeat_succeeded);
82
83 return ret;
84 }
85
102 _command_started = std::move(command_started);
103 return *this;
104 }
105
111 std::function<void MONGOCXX_ABI_CDECL(events::command_started_event const&)> const& command_started() const {
112 return _command_started;
113 }
114
130 _command_failed = std::move(command_failed);
131 return *this;
132 }
133
139 std::function<void MONGOCXX_ABI_CDECL(events::command_failed_event const&)> const& command_failed() const {
140 return _command_failed;
141 }
142
159 _command_succeeded = std::move(command_succeeded);
160 return *this;
161 }
162
168 std::function<void MONGOCXX_ABI_CDECL(events::command_succeeded_event const&)> const& command_succeeded() const {
169 return _command_succeeded;
170 }
171
187 _server_opening = std::move(server_opening);
188 return *this;
189 }
190
196 std::function<void MONGOCXX_ABI_CDECL(events::server_opening_event const&)> const& server_opening() const {
197 return _server_opening;
198 }
199
215 _server_closed = std::move(server_closed);
216 return *this;
217 }
218
224 std::function<void MONGOCXX_ABI_CDECL(events::server_closed_event const&)> const& server_closed() const {
225 return _server_closed;
226 }
227
244 _server_changed = std::move(server_changed);
245 return *this;
246 }
247
253 std::function<void MONGOCXX_ABI_CDECL(events::server_changed_event const&)> const& server_changed() const {
254 return _server_changed;
255 }
256
273 _topology_opening = std::move(topology_opening);
274 return *this;
275 }
276
282 std::function<void MONGOCXX_ABI_CDECL(events::topology_opening_event const&)> const& topology_opening() const {
283 return _topology_opening;
284 }
285
302 _topology_closed = std::move(topology_closed);
303 return *this;
304 }
305
311 std::function<void MONGOCXX_ABI_CDECL(events::topology_closed_event const&)> const& topology_closed() const {
312 return _topology_closed;
313 }
314
332 _topology_changed = std::move(topology_changed);
333 return *this;
334 }
335
341 std::function<void MONGOCXX_ABI_CDECL(events::topology_changed_event const&)> const& topology_changed() const {
342 return _topology_changed;
343 }
344
361 _heartbeat_started = std::move(heartbeat_started);
362 return *this;
363 }
364
370 std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_started_event const&)> const& heartbeat_started() const {
371 return _heartbeat_started;
372 }
373
390 _heartbeat_failed = std::move(heartbeat_failed);
391 return *this;
392 }
393
399 std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_failed_event const&)> const& heartbeat_failed() const {
400 return _heartbeat_failed;
401 }
402
420 _heartbeat_succeeded = std::move(heartbeat_succeeded);
421 return *this;
422 }
423
430 const {
431 return _heartbeat_succeeded;
432 }
433
434 private:
435 std::function<void MONGOCXX_ABI_CDECL(events::command_started_event const&)> _command_started;
436 std::function<void MONGOCXX_ABI_CDECL(events::command_failed_event const&)> _command_failed;
437 std::function<void MONGOCXX_ABI_CDECL(events::command_succeeded_event const&)> _command_succeeded;
438 std::function<void MONGOCXX_ABI_CDECL(events::server_closed_event const&)> _server_closed;
439 std::function<void MONGOCXX_ABI_CDECL(events::server_changed_event const&)> _server_changed;
440 std::function<void MONGOCXX_ABI_CDECL(events::server_opening_event const&)> _server_opening;
441 std::function<void MONGOCXX_ABI_CDECL(events::topology_closed_event const&)> _topology_closed;
442 std::function<void MONGOCXX_ABI_CDECL(events::topology_changed_event const&)> _topology_changed;
443 std::function<void MONGOCXX_ABI_CDECL(events::topology_opening_event const&)> _topology_opening;
444 std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_started_event const&)> _heartbeat_started;
445 std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_failed_event const&)> _heartbeat_failed;
446 std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_succeeded_event const&)> _heartbeat_succeeded;
447};
448
449} // namespace options
450} // namespace v_noabi
451} // namespace mongocxx
452
453namespace mongocxx {
454namespace v_noabi {
455
460 return {std::move(v)};
461}
462
467 return v1::apm{v};
468}
469
470} // namespace v_noabi
471} // namespace mongocxx
472
474
apm()=default
Default initialization.
Options related to Application Performance Monitoring (APM) configuration.
Definition apm.hpp:51
apm & on_server_description_changed(std::function< void(v1::events::server_description_changed const &)> fn)
Set the "ServerDescriptionChangedEvent" handler.
apm & on_server_opening(std::function< void(v1::events::server_opening const &)> fn)
Set the "ServerOpeningEvent" handler.
apm & on_server_closed(std::function< void(v1::events::server_closed const &)> fn)
Set the "ServerClosedEvent" handler.
apm & on_topology_opening(std::function< void(v1::events::topology_opening const &)> fn)
Set the "TopologyOpeningEvent" handler.
apm & on_command_started(std::function< void(v1::events::command_started const &)> fn)
Set the "CommandStartedEvent" handler.
apm & on_topology_closed(std::function< void(v1::events::topology_closed const &)> fn)
Set the "TopologyClosedEvent" handler.
apm & on_topology_description_changed(std::function< void(v1::events::topology_description_changed const &)> fn)
Set the "TopologyDescriptionChangedEvent" handler.
apm & on_server_heartbeat_failed(std::function< void(v1::events::server_heartbeat_failed const &)> fn)
Set the "ServerHeartbeatFailedEvent" handler.
apm & on_server_heartbeat_succeeded(std::function< void(v1::events::server_heartbeat_succeeded const &)> fn)
Set the "ServerHeartbeatSucceededEvent" handler.
apm & on_server_heartbeat_started(std::function< void(v1::events::server_heartbeat_started const &)> fn)
Set the "ServerHeartbeatStartedEvent" handler.
apm & on_command_succeeded(std::function< void(v1::events::command_succeeded const &)> fn)
Set the "CommandSucceededEvent" handler.
apm & on_command_failed(std::function< void(v1::events::command_failed const &)> fn)
Set the "CommandFailedEvent" handler.
The failed execution of a MongoDB command.
Definition command_failed_event.hpp:43
The start of the execution of a MongoDB command.
Definition command_started_event.hpp:43
The successful execution of a MongoDB command.
Definition command_succeeded_event.hpp:43
The failed execution of a heartbeat ("hello") command.
Definition heartbeat_failed_event.hpp:40
The start of the execution of a heartbeat ("hello") command.
Definition heartbeat_started_event.hpp:40
The successful execution of a heartbeat ("hello") command.
Definition heartbeat_succeeded_event.hpp:40
A change in the description of a connected MongoDB server.
Definition server_changed_event.hpp:42
The closing of a connection to a shutdown MongoDB server.
Definition server_closed_event.hpp:42
The addition of a new MongoDB server to the topology description.
Definition server_opening_event.hpp:40
A change in the topology description (including its server descriptions).
Definition topology_changed_event.hpp:39
The closing of connections to a topology of shutdown MongoDB servers.
Definition topology_closed_event.hpp:37
A new connection to a topology of MongoDB servers.
Definition topology_opening_event.hpp:39
Used by mongocxx::v_noabi::options::client::apm_opts.
Definition apm.hpp:52
std::function< void(events::heartbeat_started_event const &)> const & heartbeat_started() const
Retrieves the heartbeat started monitoring callback.
Definition apm.hpp:370
apm()=default
Default initialization.
apm & on_server_opening(std::function< void(events::server_opening_event const &)> server_opening)
Set the server opening monitoring callback. The callback takes a reference to a server_opening_event ...
Definition apm.hpp:186
apm & on_heartbeat_started(std::function< void(events::heartbeat_started_event const &)> heartbeat_started)
Set the heartbeat started monitoring callback. The callback takes a reference to a heartbeat_started_...
Definition apm.hpp:359
std::function< void(events::topology_opening_event const &)> const & topology_opening() const
Retrieves the topology_opening monitoring callback.
Definition apm.hpp:282
std::function< void(events::command_succeeded_event const &)> const & command_succeeded() const
Retrieves the command succeeded monitoring callback.
Definition apm.hpp:168
apm & on_heartbeat_failed(std::function< void(events::heartbeat_failed_event const &)> heartbeat_failed)
Set the heartbeat failed monitoring callback. The callback takes a reference to a heartbeat_failed_ev...
Definition apm.hpp:388
apm & on_server_changed(std::function< void(events::server_changed_event const &)> server_changed)
Set the server description changed monitoring callback. The callback takes a reference to a server_ch...
Definition apm.hpp:243
apm & on_heartbeat_succeeded(std::function< void(events::heartbeat_succeeded_event const &)> heartbeat_succeeded)
Set the heartbeat succeeded monitoring callback. The callback takes a reference to a heartbeat_succee...
Definition apm.hpp:418
std::function< void(events::server_closed_event const &)> const & server_closed() const
Retrieves the server closed monitoring callback.
Definition apm.hpp:224
std::function< void(events::command_failed_event const &)> const & command_failed() const
Retrieves the command failed monitoring callback.
Definition apm.hpp:139
std::function< void(events::server_opening_event const &)> const & server_opening() const
Retrieves the server opening monitoring callback.
Definition apm.hpp:196
std::function< void(events::heartbeat_succeeded_event const &)> const & heartbeat_succeeded() const
Retrieves the heartbeat succeeded monitoring callback.
Definition apm.hpp:429
std::function< void(events::heartbeat_failed_event const &)> const & heartbeat_failed() const
Retrieves the heartbeat failed monitoring callback.
Definition apm.hpp:399
std::function< void(events::command_started_event const &)> const & command_started() const
Retrieves the command started monitoring callback.
Definition apm.hpp:111
apm & on_server_closed(std::function< void(events::server_closed_event const &)> server_closed)
Set the server closed monitoring callback. The callback takes a reference to a server_closed_event wh...
Definition apm.hpp:214
apm & on_topology_opening(std::function< void(events::topology_opening_event const &)> topology_opening)
Set the topology_opening monitoring callback. The callback takes a reference to a topology_opening_ev...
Definition apm.hpp:271
std::function< void(events::topology_changed_event const &)> const & topology_changed() const
Retrieves the topology description changed monitoring callback.
Definition apm.hpp:341
std::function< void(events::topology_closed_event const &)> const & topology_closed() const
Retrieves the topology closed monitoring callback.
Definition apm.hpp:311
apm & on_command_succeeded(std::function< void(events::command_succeeded_event const &)> command_succeeded)
Set the command succeeded monitoring callback. The callback takes a reference to a command_succeeded_...
Definition apm.hpp:157
apm & on_topology_closed(std::function< void(events::topology_closed_event const &)> topology_closed)
Set the topology closed monitoring callback. The callback takes a reference to a topology_closed_even...
Definition apm.hpp:300
std::function< void(events::server_changed_event const &)> const & server_changed() const
Retrieves the server description changed monitoring callback.
Definition apm.hpp:253
apm & on_command_failed(std::function< void(events::command_failed_event const &)> command_failed)
Set the command failed monitoring callback. The callback takes a reference to a command_failed_event ...
Definition apm.hpp:129
apm & on_command_started(std::function< void(events::command_started_event const &)> command_started)
Set the command started monitoring callback. The callback takes a reference to a command_started_even...
Definition apm.hpp:100
apm & on_topology_changed(std::function< void(events::topology_changed_event const &)> topology_changed)
Set the topology description changed monitoring callback. The callback takes a reference to a topolog...
Definition apm.hpp:330
Provides mongocxx::v_noabi::events::command_failed_event.
Provides mongocxx::v_noabi::events::command_started_event.
Provides mongocxx::v_noabi::events::command_succeeded_event.
Provides mongocxx::v_noabi::events::heartbeat_failed_event.
Provides mongocxx::v_noabi::events::heartbeat_started_event.
Provides mongocxx::v_noabi::events::heartbeat_succeeded_event.
#define MONGOCXX_ABI_CDECL
Expands to __cdecl when built with MSVC on Windows.
Definition export.hpp:49
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v_noabi::events::server_changed_event.
Provides mongocxx::v_noabi::events::server_closed_event.
Provides mongocxx::v_noabi::events::server_opening_event.
Provides mongocxx::v_noabi::events::topology_changed_event.
Provides mongocxx::v_noabi::events::topology_closed_event.
Provides mongocxx::v_noabi::events::topology_opening_event.
Provides mongocxx::v1::apm.
Declares mongocxx::v_noabi::options::apm.