server_opening_event.hpp 1.8 KB

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