Loading...
Searching...
No Matches
apm.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/apm-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/apm.hpp> // IWYU pragma: export
#include <functional>
#include <utility>
#include <mongocxx/events/command_failed_event.hpp>
#include <mongocxx/events/command_started_event.hpp>
#include <mongocxx/events/command_succeeded_event.hpp>
#include <mongocxx/events/heartbeat_failed_event.hpp>
#include <mongocxx/events/heartbeat_started_event.hpp>
#include <mongocxx/events/heartbeat_succeeded_event.hpp>
#include <mongocxx/events/server_changed_event.hpp>
#include <mongocxx/events/server_closed_event.hpp>
#include <mongocxx/events/server_opening_event.hpp>
#include <mongocxx/events/topology_changed_event.hpp>
#include <mongocxx/events/topology_closed_event.hpp>
#include <mongocxx/events/topology_opening_event.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class apm {
public:
apm() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() apm(v1::apm other);
explicit operator v1::apm() const {
v1::apm ret;
ret.on_command_started(_command_started);
ret.on_command_failed(_command_failed);
ret.on_command_succeeded(_command_succeeded);
ret.on_server_closed(_server_closed);
ret.on_server_description_changed(_server_changed);
ret.on_server_opening(_server_opening);
ret.on_topology_closed(_topology_closed);
ret.on_topology_description_changed(_topology_changed);
ret.on_topology_opening(_topology_opening);
ret.on_server_heartbeat_started(_heartbeat_started);
ret.on_server_heartbeat_failed(_heartbeat_failed);
ret.on_server_heartbeat_succeeded(_heartbeat_succeeded);
return ret;
}
apm& on_command_started(
std::function<void MONGOCXX_ABI_CDECL(events::command_started_event const&)> command_started) {
_command_started = std::move(command_started);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::command_started_event const&)> const& command_started() const {
return _command_started;
}
apm& on_command_failed(std::function<void MONGOCXX_ABI_CDECL(events::command_failed_event const&)> command_failed) {
_command_failed = std::move(command_failed);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::command_failed_event const&)> const& command_failed() const {
return _command_failed;
}
apm& on_command_succeeded(
std::function<void MONGOCXX_ABI_CDECL(events::command_succeeded_event const&)> command_succeeded) {
_command_succeeded = std::move(command_succeeded);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::command_succeeded_event const&)> const& command_succeeded() const {
return _command_succeeded;
}
apm& on_server_opening(std::function<void MONGOCXX_ABI_CDECL(events::server_opening_event const&)> server_opening) {
_server_opening = std::move(server_opening);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::server_opening_event const&)> const& server_opening() const {
return _server_opening;
}
apm& on_server_closed(std::function<void MONGOCXX_ABI_CDECL(events::server_closed_event const&)> server_closed) {
_server_closed = std::move(server_closed);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::server_closed_event const&)> const& server_closed() const {
return _server_closed;
}
apm& on_server_changed(std::function<void MONGOCXX_ABI_CDECL(events::server_changed_event const&)> server_changed) {
_server_changed = std::move(server_changed);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::server_changed_event const&)> const& server_changed() const {
return _server_changed;
}
apm& on_topology_opening(
std::function<void MONGOCXX_ABI_CDECL(events::topology_opening_event const&)> topology_opening) {
_topology_opening = std::move(topology_opening);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::topology_opening_event const&)> const& topology_opening() const {
return _topology_opening;
}
apm& on_topology_closed(
std::function<void MONGOCXX_ABI_CDECL(events::topology_closed_event const&)> topology_closed) {
_topology_closed = std::move(topology_closed);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::topology_closed_event const&)> const& topology_closed() const {
return _topology_closed;
}
apm& on_topology_changed(
std::function<void MONGOCXX_ABI_CDECL(events::topology_changed_event const&)> topology_changed) {
_topology_changed = std::move(topology_changed);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::topology_changed_event const&)> const& topology_changed() const {
return _topology_changed;
}
apm& on_heartbeat_started(
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_started_event const&)> heartbeat_started) {
_heartbeat_started = std::move(heartbeat_started);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_started_event const&)> const& heartbeat_started() const {
return _heartbeat_started;
}
apm& on_heartbeat_failed(
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_failed_event const&)> heartbeat_failed) {
_heartbeat_failed = std::move(heartbeat_failed);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_failed_event const&)> const& heartbeat_failed() const {
return _heartbeat_failed;
}
apm& on_heartbeat_succeeded(
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_succeeded_event const&)> heartbeat_succeeded) {
_heartbeat_succeeded = std::move(heartbeat_succeeded);
return *this;
}
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_succeeded_event const&)> const& heartbeat_succeeded()
const {
return _heartbeat_succeeded;
}
private:
std::function<void MONGOCXX_ABI_CDECL(events::command_started_event const&)> _command_started;
std::function<void MONGOCXX_ABI_CDECL(events::command_failed_event const&)> _command_failed;
std::function<void MONGOCXX_ABI_CDECL(events::command_succeeded_event const&)> _command_succeeded;
std::function<void MONGOCXX_ABI_CDECL(events::server_closed_event const&)> _server_closed;
std::function<void MONGOCXX_ABI_CDECL(events::server_changed_event const&)> _server_changed;
std::function<void MONGOCXX_ABI_CDECL(events::server_opening_event const&)> _server_opening;
std::function<void MONGOCXX_ABI_CDECL(events::topology_closed_event const&)> _topology_closed;
std::function<void MONGOCXX_ABI_CDECL(events::topology_changed_event const&)> _topology_changed;
std::function<void MONGOCXX_ABI_CDECL(events::topology_opening_event const&)> _topology_opening;
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_started_event const&)> _heartbeat_started;
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_failed_event const&)> _heartbeat_failed;
std::function<void MONGOCXX_ABI_CDECL(events::heartbeat_succeeded_event const&)> _heartbeat_succeeded;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::apm from_v1(v1::apm v) {
return {std::move(v)};
}
inline v1::apm to_v1(v_noabi::options::apm const& v) {
return v1::apm{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
mongocxx::options::apm::apm
apm()=default
Default initialization.
mongocxx::v1::apm
Options related to Application Performance Monitoring (APM) configuration.
Definition apm.hpp:51
mongocxx::v1::apm::on_server_description_changed
apm & on_server_description_changed(std::function< void(v1::events::server_description_changed const &)> fn)
Set the "ServerDescriptionChangedEvent" handler.
mongocxx::v1::apm::on_server_opening
apm & on_server_opening(std::function< void(v1::events::server_opening const &)> fn)
Set the "ServerOpeningEvent" handler.
mongocxx::v1::apm::on_server_closed
apm & on_server_closed(std::function< void(v1::events::server_closed const &)> fn)
Set the "ServerClosedEvent" handler.
mongocxx::v1::apm::on_topology_opening
apm & on_topology_opening(std::function< void(v1::events::topology_opening const &)> fn)
Set the "TopologyOpeningEvent" handler.
mongocxx::v1::apm::on_command_started
apm & on_command_started(std::function< void(v1::events::command_started const &)> fn)
Set the "CommandStartedEvent" handler.
mongocxx::v1::apm::on_topology_closed
apm & on_topology_closed(std::function< void(v1::events::topology_closed const &)> fn)
Set the "TopologyClosedEvent" handler.
mongocxx::v1::apm::on_topology_description_changed
apm & on_topology_description_changed(std::function< void(v1::events::topology_description_changed const &)> fn)
Set the "TopologyDescriptionChangedEvent" handler.
mongocxx::v1::apm::on_server_heartbeat_failed
apm & on_server_heartbeat_failed(std::function< void(v1::events::server_heartbeat_failed const &)> fn)
Set the "ServerHeartbeatFailedEvent" handler.
mongocxx::v1::apm::on_server_heartbeat_succeeded
apm & on_server_heartbeat_succeeded(std::function< void(v1::events::server_heartbeat_succeeded const &)> fn)
Set the "ServerHeartbeatSucceededEvent" handler.
mongocxx::v1::apm::on_server_heartbeat_started
apm & on_server_heartbeat_started(std::function< void(v1::events::server_heartbeat_started const &)> fn)
Set the "ServerHeartbeatStartedEvent" handler.
mongocxx::v1::apm::on_command_succeeded
apm & on_command_succeeded(std::function< void(v1::events::command_succeeded const &)> fn)
Set the "CommandSucceededEvent" handler.
mongocxx::v1::apm::on_command_failed
apm & on_command_failed(std::function< void(v1::events::command_failed const &)> fn)
Set the "CommandFailedEvent" handler.
mongocxx::v_noabi::events::command_failed_event
The failed execution of a MongoDB command.
Definition command_failed_event.hpp:43
mongocxx::v_noabi::events::command_started_event
The start of the execution of a MongoDB command.
Definition command_started_event.hpp:43
mongocxx::v_noabi::events::command_succeeded_event
The successful execution of a MongoDB command.
Definition command_succeeded_event.hpp:43
mongocxx::v_noabi::events::heartbeat_failed_event
The failed execution of a heartbeat ("hello") command.
Definition heartbeat_failed_event.hpp:40
mongocxx::v_noabi::events::heartbeat_started_event
The start of the execution of a heartbeat ("hello") command.
Definition heartbeat_started_event.hpp:40
mongocxx::v_noabi::events::heartbeat_succeeded_event
The successful execution of a heartbeat ("hello") command.
Definition heartbeat_succeeded_event.hpp:40
mongocxx::v_noabi::events::server_changed_event
A change in the description of a connected MongoDB server.
Definition server_changed_event.hpp:42
mongocxx::v_noabi::events::server_closed_event
The closing of a connection to a shutdown MongoDB server.
Definition server_closed_event.hpp:42
mongocxx::v_noabi::events::server_opening_event
The addition of a new MongoDB server to the topology description.
Definition server_opening_event.hpp:40
mongocxx::v_noabi::events::topology_changed_event
A change in the topology description (including its server descriptions).
Definition topology_changed_event.hpp:39
mongocxx::v_noabi::events::topology_closed_event
The closing of connections to a topology of shutdown MongoDB servers.
Definition topology_closed_event.hpp:37
mongocxx::v_noabi::events::topology_opening_event
A new connection to a topology of MongoDB servers.
Definition topology_opening_event.hpp:39
mongocxx::v_noabi::options::apm
Used by mongocxx::v_noabi::options::client::apm_opts.
Definition apm.hpp:52
mongocxx::v_noabi::options::apm::heartbeat_started
std::function< void(events::heartbeat_started_event const &)> const & heartbeat_started() const
Retrieves the heartbeat started monitoring callback.
Definition apm.hpp:370
mongocxx::v_noabi::options::apm::apm
apm()=default
Default initialization.
mongocxx::v_noabi::options::apm::on_server_opening
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
mongocxx::v_noabi::options::apm::on_heartbeat_started
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
mongocxx::v_noabi::options::apm::topology_opening
std::function< void(events::topology_opening_event const &)> const & topology_opening() const
Retrieves the topology_opening monitoring callback.
Definition apm.hpp:282
mongocxx::v_noabi::options::apm::command_succeeded
std::function< void(events::command_succeeded_event const &)> const & command_succeeded() const
Retrieves the command succeeded monitoring callback.
Definition apm.hpp:168
mongocxx::v_noabi::options::apm::on_heartbeat_failed
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
mongocxx::v_noabi::options::apm::on_server_changed
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
mongocxx::v_noabi::options::apm::on_heartbeat_succeeded
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
mongocxx::v_noabi::options::apm::server_closed
std::function< void(events::server_closed_event const &)> const & server_closed() const
Retrieves the server closed monitoring callback.
Definition apm.hpp:224
mongocxx::v_noabi::options::apm::command_failed
std::function< void(events::command_failed_event const &)> const & command_failed() const
Retrieves the command failed monitoring callback.
Definition apm.hpp:139
mongocxx::v_noabi::options::apm::server_opening
std::function< void(events::server_opening_event const &)> const & server_opening() const
Retrieves the server opening monitoring callback.
Definition apm.hpp:196
mongocxx::v_noabi::options::apm::heartbeat_succeeded
std::function< void(events::heartbeat_succeeded_event const &)> const & heartbeat_succeeded() const
Retrieves the heartbeat succeeded monitoring callback.
Definition apm.hpp:429
mongocxx::v_noabi::options::apm::heartbeat_failed
std::function< void(events::heartbeat_failed_event const &)> const & heartbeat_failed() const
Retrieves the heartbeat failed monitoring callback.
Definition apm.hpp:399
mongocxx::v_noabi::options::apm::command_started
std::function< void(events::command_started_event const &)> const & command_started() const
Retrieves the command started monitoring callback.
Definition apm.hpp:111
mongocxx::v_noabi::options::apm::on_server_closed
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
mongocxx::v_noabi::options::apm::on_topology_opening
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
mongocxx::v_noabi::options::apm::topology_changed
std::function< void(events::topology_changed_event const &)> const & topology_changed() const
Retrieves the topology description changed monitoring callback.
Definition apm.hpp:341
mongocxx::v_noabi::options::apm::topology_closed
std::function< void(events::topology_closed_event const &)> const & topology_closed() const
Retrieves the topology closed monitoring callback.
Definition apm.hpp:311
mongocxx::v_noabi::options::apm::on_command_succeeded
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
mongocxx::v_noabi::options::apm::on_topology_closed
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
mongocxx::v_noabi::options::apm::server_changed
std::function< void(events::server_changed_event const &)> const & server_changed() const
Retrieves the server description changed monitoring callback.
Definition apm.hpp:253
mongocxx::v_noabi::options::apm::on_command_failed
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
mongocxx::v_noabi::options::apm::on_command_started
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
mongocxx::v_noabi::options::apm::on_topology_changed
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
command_failed_event.hpp
Provides mongocxx::v_noabi::events::command_failed_event.
command_started_event.hpp
Provides mongocxx::v_noabi::events::command_started_event.
command_succeeded_event.hpp
Provides mongocxx::v_noabi::events::command_succeeded_event.
heartbeat_failed_event.hpp
Provides mongocxx::v_noabi::events::heartbeat_failed_event.
heartbeat_started_event.hpp
Provides mongocxx::v_noabi::events::heartbeat_started_event.
heartbeat_succeeded_event.hpp
Provides mongocxx::v_noabi::events::heartbeat_succeeded_event.
MONGOCXX_ABI_CDECL
#define MONGOCXX_ABI_CDECL
Expands to __cdecl when built with MSVC on Windows.
Definition export.hpp:49
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
server_changed_event.hpp
Provides mongocxx::v_noabi::events::server_changed_event.
server_closed_event.hpp
Provides mongocxx::v_noabi::events::server_closed_event.
server_opening_event.hpp
Provides mongocxx::v_noabi::events::server_opening_event.
topology_changed_event.hpp
Provides mongocxx::v_noabi::events::topology_changed_event.
topology_closed_event.hpp
Provides mongocxx::v_noabi::events::topology_closed_event.
topology_opening_event.hpp
Provides mongocxx::v_noabi::events::topology_opening_event.
apm.hpp
Provides mongocxx::v1::apm.
apm-fwd.hpp
Declares mongocxx::v_noabi::options::apm.