server_changed_event.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/events/server_description.hpp>
  18. #include <mongocxx/config/prelude.hpp>
  19. namespace mongocxx {
  20. MONGOCXX_INLINE_NAMESPACE_BEGIN
  21. namespace events {
  22. ///
  23. /// An event notification sent when the driver observes a change in the status of a server it is
  24. /// connected to.
  25. ///
  26. /// @see "ServerDescriptionChangedEvent" in
  27. /// https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst
  28. ///
  29. class MONGOCXX_API server_changed_event {
  30. public:
  31. MONGOCXX_PRIVATE explicit server_changed_event(const void* event);
  32. ///
  33. /// Destroys a server_changed_event.
  34. ///
  35. ~server_changed_event();
  36. ///
  37. /// Returns the server host name.
  38. ///
  39. /// @return The host name.
  40. ///
  41. bsoncxx::stdx::string_view host() const;
  42. ///
  43. /// Returns the server port.
  44. ///
  45. /// @return The port.
  46. ///
  47. std::uint16_t port() const;
  48. ///
  49. /// An opaque id, unique to this topology for this mongocxx::client or mongocxx::pool.
  50. ///
  51. /// @return The id.
  52. ///
  53. const bsoncxx::oid topology_id() const;
  54. ///
  55. /// The server's description before it changed.
  56. ///
  57. /// @return The server_description.
  58. ///
  59. const server_description previous_description() const;
  60. ///
  61. /// The server's description after it changed.
  62. ///
  63. /// @return The server_description.
  64. ///
  65. const server_description new_description() const;
  66. private:
  67. const void* _event;
  68. };
  69. } // namespace events
  70. MONGOCXX_INLINE_NAMESPACE_END
  71. } // namespace mongocxx
  72. #include <mongocxx/config/postlude.hpp>