123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- // Copyright 2018-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 <functional>
- #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 {
- MONGOCXX_INLINE_NAMESPACE_BEGIN
- namespace options {
- class MONGOCXX_API apm {
- public:
- ///
- /// Set the command started monitoring callback. The callback takes a reference to a
- /// command_started_event which will only contain valid data for the duration of the callback.
- ///
- /// @param command_started
- /// The command started monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_command_started(
- std::function<void(const mongocxx::events::command_started_event&)> command_started);
- ///
- /// Retrieves the command started monitoring callback.
- ///
- /// @return The command started monitoring callback.
- ///
- const std::function<void(const mongocxx::events::command_started_event&)>& command_started()
- const;
- ///
- /// Set the command failed monitoring callback. The callback takes a reference to a
- /// command_failed_event which will only contain valid data for the duration of the callback.
- ///
- /// @param command_failed
- /// The command failed monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_command_failed(
- std::function<void(const mongocxx::events::command_failed_event&)> command_failed);
- ///
- /// Retrieves the command failed monitoring callback.
- ///
- /// @return The command failed monitoring callback.
- ///
- const std::function<void(const mongocxx::events::command_failed_event&)>& command_failed()
- const;
- ///
- /// Set the command succeeded monitoring callback. The callback takes a reference to a
- /// command_succeeded_event which will only contain valid data for the duration of the callback.
- ///
- /// @param command_succeeded
- /// The command succeeded monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_command_succeeded(
- std::function<void(const mongocxx::events::command_succeeded_event&)> command_succeeded);
- ///
- /// Retrieves the command succeeded monitoring callback.
- ///
- /// @return The command succeeded monitoring callback.
- ///
- const std::function<void(const mongocxx::events::command_succeeded_event&)>& command_succeeded()
- const;
- ///
- /// Set the server opening monitoring callback. The callback takes a reference to a
- /// server_opening_event which will only contain valid data for the duration of the callback.
- ///
- /// @param server_opening
- /// The server opening monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_server_opening(
- std::function<void(const mongocxx::events::server_opening_event&)> server_opening);
- ///
- /// Retrieves the server opening monitoring callback.
- ///
- /// @return The server opening monitoring callback.
- ///
- const std::function<void(const mongocxx::events::server_opening_event&)>& server_opening()
- const;
- ///
- /// Set the server closed monitoring callback. The callback takes a reference to a
- /// server_closed_event which will only contain valid data for the duration of the callback.
- ///
- /// @param server_closed
- /// The server closed monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_server_closed(
- std::function<void(const mongocxx::events::server_closed_event&)> server_closed);
- ///
- /// Retrieves the server closed monitoring callback.
- ///
- /// @return The server closed monitoring callback.
- ///
- const std::function<void(const mongocxx::events::server_closed_event&)>& server_closed() const;
- ///
- /// Set the server description changed monitoring callback. The callback takes a reference to a
- /// server_changed_event which will only contain valid data for the duration of the
- /// callback.
- ///
- /// @param server_changed
- /// The server description changed monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_server_changed(
- std::function<void(const mongocxx::events::server_changed_event&)> server_changed);
- ///
- /// Retrieves the server description changed monitoring callback.
- ///
- /// @return The server description changed monitoring callback.
- ///
- const std::function<void(const mongocxx::events::server_changed_event&)>& server_changed()
- const;
- ///
- /// Set the topology_opening monitoring callback. The callback takes a reference to a
- /// topology_opening_event which will only contain valid data for the duration of the callback.
- ///
- /// @param topology_opening
- /// The topology_opening monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_topology_opening(
- std::function<void(const mongocxx::events::topology_opening_event&)> topology_opening);
- ///
- /// Retrieves the topology_opening monitoring callback.
- ///
- /// @return The topology_opening monitoring callback.
- ///
- const std::function<void(const mongocxx::events::topology_opening_event&)>& topology_opening()
- const;
- ///
- /// Set the topology closed monitoring callback. The callback takes a reference to a
- /// topology_closed_event which will only contain valid data for the duration of the callback.
- ///
- /// @param topology_closed
- /// The topology closed monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_topology_closed(
- std::function<void(const mongocxx::events::topology_closed_event&)> topology_closed);
- ///
- /// Retrieves the topology closed monitoring callback.
- ///
- /// @return The topology closed monitoring callback.
- ///
- const std::function<void(const mongocxx::events::topology_closed_event&)>& topology_closed()
- const;
- ///
- /// Set the topology description changed monitoring callback. The callback takes a reference to
- /// a
- /// topology_changed_event which will only contain valid data for the duration of
- /// the callback.
- ///
- /// @param topology_changed
- /// The topology description changed monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_topology_changed(
- std::function<void(const mongocxx::events::topology_changed_event&)> topology_changed);
- ///
- /// Retrieves the topology description changed monitoring callback.
- ///
- /// @return The topology description changed monitoring callback.
- ///
- const std::function<void(const mongocxx::events::topology_changed_event&)>& topology_changed()
- const;
- ///
- /// Set the heartbeat started monitoring callback. The callback takes a reference to a
- /// heartbeat_started_event which will only contain valid data for the duration of the callback.
- ///
- /// @param heartbeat_started
- /// The heartbeat started monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_heartbeat_started(
- std::function<void(const mongocxx::events::heartbeat_started_event&)> heartbeat_started);
- ///
- /// Retrieves the heartbeat started monitoring callback.
- ///
- /// @return The heartbeat started monitoring callback.
- ///
- const std::function<void(const mongocxx::events::heartbeat_started_event&)>& heartbeat_started()
- const;
- ///
- /// Set the heartbeat failed monitoring callback. The callback takes a reference to a
- /// heartbeat_failed_event which will only contain valid data for the duration of the callback.
- ///
- /// @param heartbeat_failed
- /// The heartbeat failed monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_heartbeat_failed(
- std::function<void(const mongocxx::events::heartbeat_failed_event&)> heartbeat_failed);
- ///
- /// Retrieves the heartbeat failed monitoring callback.
- ///
- /// @return The heartbeat failed monitoring callback.
- ///
- const std::function<void(const mongocxx::events::heartbeat_failed_event&)>& heartbeat_failed()
- const;
- ///
- /// Set the heartbeat succeeded monitoring callback. The callback takes a reference to a
- /// heartbeat_succeeded_event which will only contain valid data for the duration of the
- /// callback.
- ///
- /// @param heartbeat_succeeded
- /// The heartbeat succeeded monitoring callback.
- ///
- /// @return
- /// A reference to the object on which this member function is being called. This facilitates
- /// method chaining.
- ///
- apm& on_heartbeat_succeeded(
- std::function<void(const mongocxx::events::heartbeat_succeeded_event&)>
- heartbeat_succeeded);
- ///
- /// Retrieves the heartbeat succeeded monitoring callback.
- ///
- /// @return The heartbeat succeeded monitoring callback.
- ///
- const std::function<void(const mongocxx::events::heartbeat_succeeded_event&)>&
- heartbeat_succeeded() const;
- private:
- std::function<void(const mongocxx::events::command_started_event&)> _command_started;
- std::function<void(const mongocxx::events::command_failed_event&)> _command_failed;
- std::function<void(const mongocxx::events::command_succeeded_event&)> _command_succeeded;
- std::function<void(const mongocxx::events::server_closed_event&)> _server_closed;
- std::function<void(const mongocxx::events::server_changed_event&)> _server_changed;
- std::function<void(const mongocxx::events::server_opening_event&)> _server_opening;
- std::function<void(const mongocxx::events::topology_closed_event&)> _topology_closed;
- std::function<void(const mongocxx::events::topology_changed_event&)> _topology_changed;
- std::function<void(const mongocxx::events::topology_opening_event&)> _topology_opening;
- std::function<void(const mongocxx::events::heartbeat_started_event&)> _heartbeat_started;
- std::function<void(const mongocxx::events::heartbeat_failed_event&)> _heartbeat_failed;
- std::function<void(const mongocxx::events::heartbeat_succeeded_event&)> _heartbeat_succeeded;
- };
- } // namespace options
- MONGOCXX_INLINE_NAMESPACE_END
- } // namespace mongocxx
- #include <mongocxx/config/postlude.hpp>
|