topology_changed_event.hpp 2.0 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 <mongocxx/events/topology_description.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 observes a change in any of the servers it is
  23. /// connected to or a change in the overall server topology.
  24. ///
  25. /// @see "TopologyDescriptionChangedEvent" 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 topology_changed_event {
  29. public:
  30. MONGOCXX_PRIVATE explicit topology_changed_event(const void* event);
  31. ///
  32. /// Destroys a topology_changed_event.
  33. ///
  34. ~topology_changed_event();
  35. ///
  36. /// An opaque id, unique to this topology for this mongocxx::client or mongocxx::pool.
  37. ///
  38. /// @return The id.
  39. ///
  40. bsoncxx::oid topology_id() const;
  41. ///
  42. /// The server's description before it changed.
  43. ///
  44. /// @return The topology_description.
  45. ///
  46. topology_description previous_description() const;
  47. ///
  48. /// The server's description after it changed.
  49. ///
  50. /// @return The topology_description.
  51. ///
  52. topology_description new_description() 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>