server_closed_event.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2018-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. #pragma once
  15. #include <bsoncxx/oid.hpp>
  16. #include <bsoncxx/stdx/string_view.hpp>
  17. #include <mongocxx/config/prelude.hpp>
  18. namespace mongocxx {
  19. MONGOCXX_INLINE_NAMESPACE_BEGIN
  20. namespace events {
  21. ///
  22. /// An event notification sent when the driver stops monitoring a MongoDB server and removes it
  23. /// from the topology description.
  24. ///
  25. /// @see "ServerClosedEvent" in
  26. /// https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst
  27. ///
  28. class MONGOCXX_API server_closed_event {
  29. public:
  30. MONGOCXX_PRIVATE explicit server_closed_event(const void* event);
  31. ///
  32. /// Destroys a server_closed_event.
  33. ///
  34. ~server_closed_event();
  35. ///
  36. /// Returns the server host name.
  37. ///
  38. /// @return The host name.
  39. ///
  40. bsoncxx::stdx::string_view host() const;
  41. ///
  42. /// Returns the server port.
  43. ///
  44. /// @return The port.
  45. ///
  46. std::uint16_t port() const;
  47. ///
  48. /// An opaque id, unique to this topology for this mongocxx::client or mongocxx::pool.
  49. ///
  50. /// @return The id.
  51. ///
  52. const bsoncxx::oid topology_id() const;
  53. private:
  54. const void* _event;
  55. };
  56. } // namespace events
  57. MONGOCXX_INLINE_NAMESPACE_END
  58. } // namespace mongocxx
  59. #include <mongocxx/config/postlude.hpp>