heartbeat_started_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/stdx/string_view.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 begins executing an "isMaster" command to check the
  22. /// status of a server.
  23. ///
  24. /// @see "ServerHeartbeatStartedEvent" 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 heartbeat_started_event {
  28. public:
  29. MONGOCXX_PRIVATE explicit heartbeat_started_event(const void* event);
  30. ///
  31. /// Destroys a heartbeat_started_event.
  32. ///
  33. ~heartbeat_started_event();
  34. ///
  35. /// Returns the host name.
  36. ///
  37. /// @return The host name.
  38. ///
  39. bsoncxx::stdx::string_view host() const;
  40. ///
  41. /// Returns the port.
  42. ///
  43. /// @return The port.
  44. ///
  45. std::uint16_t port() const;
  46. ///
  47. /// Returns a boolean indicating whether this heartbeat event is from an awaitable isMaster.
  48. ///
  49. /// @return A boolean.
  50. ///
  51. bool awaited() const;
  52. private:
  53. const void* _started_event;
  54. };
  55. } // namespace events
  56. MONGOCXX_INLINE_NAMESPACE_END
  57. } // namespace mongocxx
  58. #include <mongocxx/config/postlude.hpp>